From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3024DA00C3; Thu, 3 Feb 2022 19:13:58 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DD7EB4068A; Thu, 3 Feb 2022 19:13:53 +0100 (CET) Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam08on2043.outbound.protection.outlook.com [40.107.102.43]) by mails.dpdk.org (Postfix) with ESMTP id 7265540DFD for ; Thu, 3 Feb 2022 19:13:52 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QbvAIpSNLHrhcRjp1ulUdPyMz0RtE5b9/AqRLDLENs8OlvV/iyZ+A3UlB0bK+zJEhmidQ8e78T7rIUfY45JdYml8HO1i7QABOQw/M7C3HQ8od6cfez87YLM0RMAtdFzAqoxpipdMii8fgyYzUBUbJR3WRgaOU4AbvPBl9Y8ORI7nIN9TZ+KCXlwU0iwqmc/uL82f/Sn7sKzVllBRLsr29sDz8lcOM2Kj+Eatg+GwyTMF/JX/ZlEdrmBQkFIRhjeslNbR0pXA/rDEPcX2307u2CeBfvrjDRbpDWGwv5U1Wnfg76PcxlWvHzaMk8EhfKoBfK4e1VunQKKD7Kk0yKeedg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VHQZhT6vRHGv6M1aykDBim+rt+aF8I6RKoc4fMoQBR0=; b=CDV/ZhxHsX9kvUUU1gjrygc3gCmBBqOjhVpL7UNnTH+BC4RhFSgeP0FNW5lBRDgOG0FQAGCEvSE6BVbhTxKg6LvwrQVcHYmDGnqXg3g3xCw2MNi3k5MMST+MKeK9xhdCdgvW7A3XtDhbhWxaiEeRlQBYrveEjrxZpFZbp+lIlETEIw08/Ql89PrmlQ7c25dDSlq28G8t0mgk5cuXdXjsTj4C7uVl/Qyrb/28y9UhTLTjDYzm9kpfPeDHSfJ+9T5vu5qUFeFg6hRu1e2kWHMSeOS6yRpDTeSzQGLK4LIudnKCzGl8KgWLfS2xY+VN+CooKj0E4/8RvEKsr+mHeGK/0g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.235) smtp.rcpttodomain=intel.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VHQZhT6vRHGv6M1aykDBim+rt+aF8I6RKoc4fMoQBR0=; b=dj4gQ8k9A/kCuiood0BoxfeOhCxIoa3p5/9GBsYNdTnRAnT6hiR3/NMf/ooRuDF00iS2kiWtMvPa799/YJj3+D5BvAcbYiEsmYhJefKjqQcHXHTRgFavgzk9RPG1DRrfSbCoA9xr73QX0mImXTz6PJLthHxy1d0Fb1xMnnaenqelOiUu0Y79ysUvrr2oK6Dzl+O3VACPTaOHR4mzfW15hT0K6TECa2zFUdhwsy5c9pSIzCmpcGzk2hyzyKpqnjkteCD4G9b1KQzuompSRysU79r6gP3svgwvc6yD3nyOIpCO3ajmjBin6ly4B6so2Ar+hd61X1VM1mcQRxtVVmAzow== Received: from BN9PR03CA0351.namprd03.prod.outlook.com (2603:10b6:408:f6::26) by DM5PR1201MB2555.namprd12.prod.outlook.com (2603:10b6:3:ea::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Thu, 3 Feb 2022 18:13:50 +0000 Received: from BN8NAM11FT060.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f6:cafe::91) by BN9PR03CA0351.outlook.office365.com (2603:10b6:408:f6::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Thu, 3 Feb 2022 18:13:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.235) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.235 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.235; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.235) by BN8NAM11FT060.mail.protection.outlook.com (10.13.177.211) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4951.12 via Frontend Transport; Thu, 3 Feb 2022 18:13:49 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 3 Feb 2022 18:13:48 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Thu, 3 Feb 2022 10:13:48 -0800 Received: from nvidia.com (10.127.8.11) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.9 via Frontend Transport; Thu, 3 Feb 2022 10:13:47 -0800 From: Dmitry Kozlyuk To: CC: Thomas Monjalon , Anatoly Burakov Subject: [PATCH v3 4/6] eal: refactor --huge-unlink storage Date: Thu, 3 Feb 2022 20:13:34 +0200 Message-ID: <20220203181337.759161-5-dkozlyuk@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220203181337.759161-1-dkozlyuk@nvidia.com> References: <20220119210917.765505-1-dkozlyuk@nvidia.com> <20220203181337.759161-1-dkozlyuk@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 823e77bd-c49a-4d4c-1fb4-08d9e740ed53 X-MS-TrafficTypeDiagnostic: DM5PR1201MB2555:EE_ X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1850; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bIZcc3SZKq5VFJjope/BWbEjqk1IK3vqfnG0XbWxr+Y0oZhWJXcWVrAtYb0Qq1xy0GTuCUh8aqJUDLUq+U+yFwujsyhDoA6V9VvS1YGENJ0SIWxaDrx8HGzPJILo+Yr2SGFGkZc4RkFZPR81vFOBar/uIkbOsaQTWfPuUNnejEEO7tIDF3UG2PksXE5YYXIbyCCVbequT+IX2fQv3KGesiZh1eP+v9Cvw5UUZTWpgM+0XaLGoOE/HOOiFslk4tCNBUkCEHSwbTSbMdocxP3rIrMIGBV//i/U3eMozCtIFGayGd8j1RpO7NSqUlah8MDtXt8/hZU6gpM2JJ9QbMOnNZ1iO1xT/L9ckwBuVzkpmiWdo+wIK8nF1jphxRd4QpJnwoNXiyHXVM1DBE7kTNnvPd8t1m+KBo/dk6t7L8ETFgTT3Vk+ByvZ2xkOsdgNaJAz7sSLeo6auj7esJt8qEUi49S1Y0SHbeF28eL9Nz+TM4w/Q4zxs3+Lovr5oaeyNDPCCAqT+GP1M99BAFsfKCWBB0LmieZBQolPCJE+sJdsKhHEAu5AN5AdUd887faWSehJLhRsV9IafRYo9Tv/nE7NV1+z0aeeCd64VlVjU+BEDCE30W3FoFj1/+ppZaK03sFDakl+17Egoj18N4PYcHkn3rUrh+qV2hrRQCc46vC26MndOj+pdRoCNavOw1l1A46pgftm+ZRTUTDne3Wqc5LqNgP6Ie+ftBcGzGh2r2KYkUc= X-Forefront-Antispam-Report: CIP:12.22.5.235; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(6666004)(316002)(54906003)(70206006)(508600001)(6916009)(2616005)(70586007)(55016003)(8676002)(82310400004)(81166007)(356005)(4326008)(86362001)(7696005)(8936002)(40460700003)(36756003)(426003)(336012)(36860700001)(5660300002)(47076005)(2906002)(1076003)(6286002)(83380400001)(26005)(186003)(14583001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2022 18:13:49.3019 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 823e77bd-c49a-4d4c-1fb4-08d9e740ed53 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.235]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT060.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1201MB2555 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org In preparation to extend --huge-unlink option semantics refactor how it is stored in the internal configuration. It makes future changes more isolated. Signed-off-by: Dmitry Kozlyuk Acked-by: Thomas Monjalon --- lib/eal/common/eal_common_options.c | 9 +++++---- lib/eal/common/eal_internal_cfg.h | 8 +++++++- lib/eal/linux/eal_memalloc.c | 7 ++++--- lib/eal/linux/eal_memory.c | 2 +- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c index 1cfdd75f3b..7520ebda8e 100644 --- a/lib/eal/common/eal_common_options.c +++ b/lib/eal/common/eal_common_options.c @@ -1737,7 +1737,7 @@ eal_parse_common_option(int opt, const char *optarg, /* long options */ case OPT_HUGE_UNLINK_NUM: - conf->hugepage_unlink = 1; + conf->hugepage_file.unlink_before_mapping = true; break; case OPT_NO_HUGE_NUM: @@ -1766,7 +1766,7 @@ eal_parse_common_option(int opt, const char *optarg, conf->in_memory = 1; /* in-memory is a superset of noshconf and huge-unlink */ conf->no_shconf = 1; - conf->hugepage_unlink = 1; + conf->hugepage_file.unlink_before_mapping = true; break; case OPT_PROC_TYPE_NUM: @@ -2050,7 +2050,8 @@ eal_check_common_options(struct internal_config *internal_cfg) "be specified together with --"OPT_NO_HUGE"\n"); return -1; } - if (internal_cfg->no_hugetlbfs && internal_cfg->hugepage_unlink && + if (internal_cfg->no_hugetlbfs && + internal_cfg->hugepage_file.unlink_before_mapping && !internal_cfg->in_memory) { RTE_LOG(ERR, EAL, "Option --"OPT_HUGE_UNLINK" cannot " "be specified together with --"OPT_NO_HUGE"\n"); @@ -2061,7 +2062,7 @@ eal_check_common_options(struct internal_config *internal_cfg) " is only supported in non-legacy memory mode\n"); } if (internal_cfg->single_file_segments && - internal_cfg->hugepage_unlink && + internal_cfg->hugepage_file.unlink_before_mapping && !internal_cfg->in_memory) { RTE_LOG(ERR, EAL, "Option --"OPT_SINGLE_FILE_SEGMENTS" is " "not compatible with --"OPT_HUGE_UNLINK"\n"); diff --git a/lib/eal/common/eal_internal_cfg.h b/lib/eal/common/eal_internal_cfg.h index d6c0470eb8..b5e6942578 100644 --- a/lib/eal/common/eal_internal_cfg.h +++ b/lib/eal/common/eal_internal_cfg.h @@ -40,6 +40,12 @@ struct simd_bitwidth { uint16_t bitwidth; /**< bitwidth value */ }; +/** Hugepage backing files discipline. */ +struct hugepage_file_discipline { + /** Unlink files before mapping them to leave no trace in hugetlbfs. */ + bool unlink_before_mapping; +}; + /** * internal configuration */ @@ -48,7 +54,7 @@ struct internal_config { volatile unsigned force_nchannel; /**< force number of channels */ volatile unsigned force_nrank; /**< force number of ranks */ volatile unsigned no_hugetlbfs; /**< true to disable hugetlbfs */ - unsigned hugepage_unlink; /**< true to unlink backing files */ + struct hugepage_file_discipline hugepage_file; volatile unsigned no_pci; /**< true to disable PCI */ volatile unsigned no_hpet; /**< true to disable HPET */ volatile unsigned vmware_tsc_map; /**< true to use VMware TSC mapping diff --git a/lib/eal/linux/eal_memalloc.c b/lib/eal/linux/eal_memalloc.c index 16b58d861b..5f5531830d 100644 --- a/lib/eal/linux/eal_memalloc.c +++ b/lib/eal/linux/eal_memalloc.c @@ -564,7 +564,7 @@ alloc_seg(struct rte_memseg *ms, void *addr, int socket_id, __func__, strerror(errno)); goto resized; } - if (internal_conf->hugepage_unlink && + if (internal_conf->hugepage_file.unlink_before_mapping && !internal_conf->in_memory) { if (unlink(path)) { RTE_LOG(DEBUG, EAL, "%s(): unlink() failed: %s\n", @@ -697,7 +697,7 @@ alloc_seg(struct rte_memseg *ms, void *addr, int socket_id, close_hugefile(fd, path, list_idx); } else { /* only remove file if we can take out a write lock */ - if (internal_conf->hugepage_unlink == 0 && + if (!internal_conf->hugepage_file.unlink_before_mapping && internal_conf->in_memory == 0 && lock(fd, LOCK_EX) == 1) unlink(path); @@ -756,7 +756,8 @@ free_seg(struct rte_memseg *ms, struct hugepage_info *hi, /* if we're able to take out a write lock, we're the last one * holding onto this page. */ - if (!internal_conf->in_memory && !internal_conf->hugepage_unlink) { + if (!internal_conf->in_memory && + !internal_conf->hugepage_file.unlink_before_mapping) { ret = lock(fd, LOCK_EX); if (ret >= 0) { /* no one else is using this page */ diff --git a/lib/eal/linux/eal_memory.c b/lib/eal/linux/eal_memory.c index 03a4f2dd2d..83eec078a4 100644 --- a/lib/eal/linux/eal_memory.c +++ b/lib/eal/linux/eal_memory.c @@ -1428,7 +1428,7 @@ eal_legacy_hugepage_init(void) } /* free the hugepage backing files */ - if (internal_conf->hugepage_unlink && + if (internal_conf->hugepage_file.unlink_before_mapping && unlink_hugepage_files(tmp_hp, internal_conf->num_hugepage_sizes) < 0) { RTE_LOG(ERR, EAL, "Unlinking hugepage files failed!\n"); goto fail; -- 2.25.1