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 EAAA3A04A5; Thu, 30 Dec 2021 15:38:28 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C5BBF4115D; Thu, 30 Dec 2021 15:38:15 +0100 (CET) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2055.outbound.protection.outlook.com [40.107.94.55]) by mails.dpdk.org (Postfix) with ESMTP id 9BC0641148 for ; Thu, 30 Dec 2021 15:38:12 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EAB1dbAIdR2MMx4ZCbP/uNBlP7t/8/MPAYTZ+5AKWewM65hwdpg9SJBmZUwf5l9rf4i09CbrPr96UnmIwqwHfDVOfslCGLiU6V4XsPWs2ymqLi4gy3FQn1XrXkYihsSFQ+hLa3WO0FLdc4llZCYoFD3Vfye74eFi0J5ufgjRlFitB0i0NCWRABVAZHdW001f7xlo8zX+z5t2b8BuTBW3ChNnb88vUsg8QIm6UBDLdX8bi7Vqo09OFzk5qsniLHiz5H85Y1303LF9wPYEqOdKQ7YMLw8qijuJncyVUFtSEf3Zx8jkYrLE+NekYPon4SQAOfPchFx4nkrydApjBckM+Q== 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=D2sMQFutSte/BN5GqkK9m7sMUXaAd3XL5o5P/r/0i/NMBvuzutYakSLPoyUTV4maKlmacmF5h6slA/CkCa++xrVODm1ZxVLRCIXqWzD1HXGfZsdiDTsm5ovsJuIFl8Jg5uUxN6ePxZu7pnJftXEeFra0uUSQCYBa4GzupdMNiMNG8IEashD0NFicoAPvsAb6rEoah6b9VLo9BY3EjEZlz/xrh9VAoz3XeYdUiHyvmQKqXgxU1dslmoyDRn3MeuGiqha2fEHwnYmJztARAX8bggkQncWHBGByQP/extrCWiR4orvocipqKeQ2VPmuv31m9AFKyr1G1bIHMKwXtx3Iwg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.236) 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=hSNkMXu0Zlqyd6SNNb6waOS4JFkpkDRlwhlgCwg3m/GUwsVBx4PNsYeHA+DWGJhYPwbt61jY6UnsvsvEjMfJ4rXno1SXZ15bWWZsTxEoFf8acc75c9lULg4MlabRqY/SJfbI++qRXKij/ADy16v0VmPmVAnQTv2/ghzAC70+XYyW8FBOhzDiy+CoGra9BTXWsVYrvAurkdHD3cR+lLWSm6LQ0f760p3rrVIkJAO6Ig+ZVPq2Ci50uYmQUJhQIxw0W4bKPVFrFy8qos0n3Dj1UYfrDiGNLONWvh6giKv4BHPsV+1M+8uyK2WNF5bPWiC7wvlhBQdLTAo5XXH8T/ja2A== Received: from CO2PR18CA0063.namprd18.prod.outlook.com (2603:10b6:104:2::31) by DM6PR12MB4985.namprd12.prod.outlook.com (2603:10b6:5:16d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.14; Thu, 30 Dec 2021 14:38:10 +0000 Received: from CO1NAM11FT053.eop-nam11.prod.protection.outlook.com (2603:10b6:104:2:cafe::ef) by CO2PR18CA0063.outlook.office365.com (2603:10b6:104:2::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.19 via Frontend Transport; Thu, 30 Dec 2021 14:38:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.236) 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.236 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.236; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.236) by CO1NAM11FT053.mail.protection.outlook.com (10.13.175.63) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4844.14 via Frontend Transport; Thu, 30 Dec 2021 14:38:10 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 30 Dec 2021 14:38:08 +0000 Received: from nvidia.com (172.20.187.6) 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; Thu, 30 Dec 2021 06:38:04 -0800 From: Dmitry Kozlyuk To: CC: Anatoly Burakov Subject: [RFC PATCH 3/6] eal: refactor --huge-unlink storage Date: Thu, 30 Dec 2021 16:37:41 +0200 Message-ID: <20211230143744.3550098-4-dkozlyuk@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211230143744.3550098-1-dkozlyuk@nvidia.com> References: <20211230143744.3550098-1-dkozlyuk@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.6] 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: de36673d-a378-47ea-3fbc-08d9cba20070 X-MS-TrafficTypeDiagnostic: DM6PR12MB4985: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: bDutFIMqN5CI1ZE1F9tXual/T+b3nZpObpC9vMlJ7YtEOYm7/BJJal9JAVUSJm2cM0SAKOJ3FeGmNJu8BongHOe53UvtAxoagZQsY1fUIcmtu4h3XM6v7n7gpPsSEcL1KGwA6zQDGk7jg5CxNou6i7Q2siDgost9R8Vh3WTVAFoeT6MNXdbeHdzuzOwKtFPQveeliVpa7QU9GX9fqJ0wFFWntGNkiNbqwr35Xq2txcfy217z1owvBStWkzvT7lYbA97Bb8UlyaEYQGnmUYceoKupd0ZXvGSX16O1iPZMgTz8FCQaFpZsGT36qkeuewvfjiP96GH3Z+eTOa//nXI/SvXdY9wDq2hLq/A8dxF8zOXLoynj/5VBBPlQwQPOQT3Av46mBcB90b2Ux2QISROdzY+HPEWrzjvmlYmVeEtmCxeMvzUH5ez1V9js0yBCFnelO4O+9iZno4GYfk34gPJ/d2BQe03XN8nDrW4oy+DYloHq4HbwL5g38obnopDbxvtp/r28IQmGVNCz/dCOBqdGzKbfmPcLbWEybSFg9tRbw6miBcHsB0hJue7scP//WciNLTIq6QsqlQGWAMyLYzaL1+PkCvUc2dJWIzoAV8SWXCd9YpuRE8ZEREUCJnN3YBRt8lG428m/+/qedll6uo6bQq6EB7CgathKgMv8rTXwOaznTOrxSOTVc8lLbe0A7fojFUDLtDOZtU+mBVcQUFoZnqvZYHQLX3B/wg0G32ZAt/8LohJ5QB6fLuvdpp6QBJsyHQwcOT3OHegqEu8lr/FkCrOETg32qye7Urws8xYaMqNJcllNT6Qmkx6oxOS/b0vqpeIFePYzZkAE6D2CmBjobA== X-Forefront-Antispam-Report: CIP:12.22.5.236; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(4636009)(46966006)(40470700002)(36840700001)(40460700001)(16526019)(186003)(1076003)(426003)(70206006)(4326008)(7696005)(6916009)(55016003)(8936002)(82310400004)(356005)(83380400001)(6666004)(86362001)(70586007)(336012)(2616005)(2906002)(8676002)(81166007)(316002)(26005)(36860700001)(36756003)(508600001)(47076005)(6286002)(5660300002)(14583001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Dec 2021 14:38:10.0882 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: de36673d-a378-47ea-3fbc-08d9cba20070 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.236]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT053.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4985 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