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 18322A034F; Mon, 17 Jan 2022 09:08:51 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C06BB4120A; Mon, 17 Jan 2022 09:08:31 +0100 (CET) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2085.outbound.protection.outlook.com [40.107.94.85]) by mails.dpdk.org (Postfix) with ESMTP id 4AA3B411C9 for ; Mon, 17 Jan 2022 09:08:28 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C2/W6zZ9CG8kdXHclircZqqtrB9RRjJzvW9I5fjb5gNQdgEemXCi0MiiVlcnIFM3ZkAa7zag/YRBAwKg/I/UJZSHinrIz7Q3kZejXMe2X5if3BKXrQA4KwnmzBRPPKui9kpUP0J0kj3Fsh3UKcCz5gjjGj3dSgvnFNgoKnJqwLacUpsGGr4aTEwXgiTeOyWbfKh+waKAsaYKcVDOPcRgNi7HN1rhQzGP64tVq5KwvMlwG3ZklMTev9NwNm317i4fC21pTcoSIbN9J9duSgUGQvngw4z0sHR+mrvnq1aJkofIeZ6vRY2XUJ9ShDIf5AFl4WwqX3NtRd3UCT3/IfC7Rg== 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=MotN3DXJjnc90k7ER7XOP0TEwbKuHQSsDOkUzmyIzf0=; b=eKdGK5olzIDKSM/PqpJey3DFvZp2/2mYgtrSFfpXFBvm9ua5Ki4VFrh+qNI73UfpUceBSA1QmQ957xWC8IWuHapNW690KFbfFhTAbcrRtOR7iV5mWLcZIzC0ztVwqOuo1lkeAjFoLWzI60J5EhYWjDdiQL8fCrxLCpIqcDsW77AiZixvZP/VXZV7wSyD86xmtzTzBoFwD+PtWk752m4qGWlO6494x2QBW9QB1a3Ly3EOakgPMNJAFrKC4JuUnX9AK9NvoApUOqbUTn5wzTRZW6ZURE0yHuMIzO7vnje76PMDxvCuJSyjfbMrY5qoHJAHDde4prGyo2PKFXkko2yYVw== 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=MotN3DXJjnc90k7ER7XOP0TEwbKuHQSsDOkUzmyIzf0=; b=QHGuYC3r5Nq1rYq4bdgITXEWVyo02+kAhDswimKvUI0J6lyZwjSjBcMeqG2wwhP3hXuPe12W+zc80K+KKOzjz7Co70Fbxkz1svJm7cWO/juSaClBrkm0m5DbovZHBSroe9s8V/iTr0yTTj+3RmA3Fd6J7E5Js7lpLAq56Xt97AOOhQmx9HWp62ljfzYbTetFvR/OhdgwarmMnmlGfT7NeFjPt/RRzAZfERggBtHV84eyoZDlrmpHvu+lkUYYmAce/gLg1N3c+4jqnP0iU6OnW7vgSFLiemvLjk69nXdetrQO1+1taEsYV0jWytoD2GtnI4hAGhgzlFwQS07dX7n2fQ== Received: from DM5PR08CA0027.namprd08.prod.outlook.com (2603:10b6:4:60::16) by BN9PR12MB5131.namprd12.prod.outlook.com (2603:10b6:408:118::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.10; Mon, 17 Jan 2022 08:08:26 +0000 Received: from DM6NAM11FT049.eop-nam11.prod.protection.outlook.com (2603:10b6:4:60:cafe::7c) by DM5PR08CA0027.outlook.office365.com (2603:10b6:4:60::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.11 via Frontend Transport; Mon, 17 Jan 2022 08:08:26 +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 DM6NAM11FT049.mail.protection.outlook.com (10.13.172.188) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4888.9 via Frontend Transport; Mon, 17 Jan 2022 08:08:25 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 17 Jan 2022 08:08:25 +0000 Received: from nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.986.9; Mon, 17 Jan 2022 00:08:23 -0800 From: Dmitry Kozlyuk To: CC: Anatoly Burakov Subject: [PATCH v1 4/6] eal: refactor --huge-unlink storage Date: Mon, 17 Jan 2022 10:07:59 +0200 Message-ID: <20220117080801.481568-5-dkozlyuk@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220117080801.481568-1-dkozlyuk@nvidia.com> References: <20211230143744.3550098-1-dkozlyuk@nvidia.com> <20220117080801.481568-1-dkozlyuk@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 655d8d69-4add-43f6-dfaf-08d9d99089c4 X-MS-TrafficTypeDiagnostic: BN9PR12MB5131:EE_ 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: n4pRxhwinC8eBVeQrLOodd4epmk585Stqxm1vpWT+KA+L6oLFAxOgr3vOFGFFohF1vMbLWlfx7dh67Hnczv10C4uwbgfXT9avaN0XeakQAp9GuIag29CmhyI+2GwQwiEtnGZtteumVT0QL6yy++T4+Lnr9g92+aUfQ0as4GB/JnGVtmHov7C/wViCVALfkG6HYYXhkjptlhcVEJg1JqMdo1x7JcmHtxSRK11yBXfb4HF9Ah8FCX8wX9/bWg3BZfU8T0cOsHjTFpoWRqI3E8pMs4TwPdf3HvVDoGO++L5xD9Iv1jjN9PYU9cyVke5wnB+vCBiKPilPIsbokVWuhnCUkk68fdA1RiWjUrx8goilImi8Z2yazlW+tjKipWlOqbda89Txy38XJZlWHxpjKTNYGtUNJ5Vi8q5FLRRSILEf3nzpV6wnnn4mpm6MImbmEtrXugr8s4wFw1mE2kHayFKRYIZw5QTGPQ4zgqHKcYy6+eXMsXNtAfWqwwNB778pS/zCCfnBmj8UI/qpUkSYgnt85FIPixtFjg/mQBj9jMyyWhXuQh8rnoQlik2uAGXuLcA9+tzuB0xXxw5yTc3pzkFz7C4jm5lmAn0N8GDXQjqORJOOF8XwYFq0bGvGPFtjp5xiVVr9KVdwF4HP03DySanU0wm5rCDV24kwFSw964QmsnqwLtNUTQlRllDkaCKM8pCEDpdc+5NGOWQA1gqMp0UbyULFzqSCb74IU7FFeaZ0pxWIBHZxOc1oVX7Fxe4JfS1XrvWlCtILdYTrEoMeQrAJmtRb4SkNVpn1+F9EqdJuTWbPwRGNh/RRDeRmeHsPuOYjOH56N6yD34Oo/qx6OCP8w== 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:(4636009)(46966006)(36840700001)(40470700002)(47076005)(70586007)(6666004)(81166007)(6916009)(2906002)(83380400001)(186003)(82310400004)(356005)(7696005)(508600001)(5660300002)(40460700001)(70206006)(8676002)(16526019)(55016003)(316002)(8936002)(4326008)(36756003)(26005)(2616005)(1076003)(6286002)(426003)(336012)(86362001)(36860700001)(14583001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2022 08:08:25.8284 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 655d8d69-4add-43f6-dfaf-08d9d99089c4 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: DM6NAM11FT049.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5131 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 --- 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 337f2bc739..abbe605e49 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