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 2AE68A0351; Wed, 19 Jan 2022 22:09:59 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2A379411DF; Wed, 19 Jan 2022 22:09:48 +0100 (CET) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1anam02on2073.outbound.protection.outlook.com [40.107.96.73]) by mails.dpdk.org (Postfix) with ESMTP id B69C4411AB for ; Wed, 19 Jan 2022 22:09:46 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DLlqGFt1O2yxpeiV6T1TnGdzH6DZTRdMWNKsqGyTWp8NgEluavubFKK3TuTNfj4G1Vsn7cF/TtKnVfx3iSaPcgmxVsJ8LwY+SGUFXssIuyYIQ45hsvaEXlE+0iy1h6Hty7vCk+ly2M7fIZmIcdClixxUeS/EOG3a1+f51FFdtVSc/wJLdt22CCdFpJwKkn5cInB2PsXHJBKYLbFNmF6j/6g7s0Wa4NFXbTN023tpYnpfDwexDe1kPxfr05RATm3msbBTXo6D/rmOR8a2Fek/Y7wLUkYQIdcMBS/pyzLjZummIPIDJ7BTnLSYUfru9tGBxo9wsv30gCMm+yID+yVGVw== 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=hqPwePR5trux0hxXfw1erDUrvsOtsQnrGCkE4PaoCHE=; b=Lj5m6KHtuCjqFLr8WMaUpjRFcQZt7J+sW+83615k+LrsAjYL+ZcYEn7/KOCla+WAN/sjlDyFXvyLOreLxb16F2qqpexGnygj+3KTnnxeuIL5zmL8Vwj4AFhMWlKVSZN7cJqDaeCqzvLzHijsE80iQ/cCorr+MWinzubZhwb05bZoAp9sbZZbb0uC58lI/JCHSJhxgheLcOMM0VO8UfoQ7Le7kpcrleinGHWvS8X3T6hrZa3ciyNrkbMIpUOuCTvZiJtaSxiVG+k+AYjR+ARVA09grNQZkhbsfkY3R2X49SaYGdUpcvkqTiVB+RBex724OX8t2nN0VsOGSh74kvmb0w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.235) smtp.rcpttodomain=monjalon.net 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=hqPwePR5trux0hxXfw1erDUrvsOtsQnrGCkE4PaoCHE=; b=eiO2kgTsNEJ357nbNfK9R2h4T5PeOUZsZ6T5T/Nda+M+CHtrCt0Itjov4c6m+oF+w0IxnWtxYXFZK8x8YUjBaLRli9VI6tCE3IedpWCfZTfqT2PAQnzK+a2rfKfpJ5585A6vMq5F9kQvQio8Ky5tbhiCDnsVT0qbh7ReSjDSjzuKJhs0bSTaDnSBvJc3UCw8BO4Ksnxqx9DZ4ef+1ePuAKzFPeqPqKywRBAxP1ecKXuRWfLodzVV12UJAlbjZZTP3sGnZzWlcj543myYdxIFz0g3dMGUis6W+UO41RUnVdoDULEd5OmQV0e/Ok+NgjBElA7yeSjI2F+5BAPTdI9PbQ== Received: from MWHPR17CA0086.namprd17.prod.outlook.com (2603:10b6:300:c2::24) by BYAPR12MB3288.namprd12.prod.outlook.com (2603:10b6:a03:130::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.8; Wed, 19 Jan 2022 21:09:44 +0000 Received: from CO1NAM11FT048.eop-nam11.prod.protection.outlook.com (2603:10b6:300:c2:cafe::42) by MWHPR17CA0086.outlook.office365.com (2603:10b6:300:c2::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.8 via Frontend Transport; Wed, 19 Jan 2022 21:09:44 +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 CO1NAM11FT048.mail.protection.outlook.com (10.13.175.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4909.7 via Frontend Transport; Wed, 19 Jan 2022 21:09:44 +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; Wed, 19 Jan 2022 21:09:40 +0000 Received: from nvidia.com (10.126.230.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; Wed, 19 Jan 2022 13:09:38 -0800 From: Dmitry Kozlyuk To: CC: Bruce Richardson , Thomas Monjalon , Anatoly Burakov Subject: [PATCH v2 4/6] eal: refactor --huge-unlink storage Date: Wed, 19 Jan 2022 23:09:15 +0200 Message-ID: <20220119210917.765505-5-dkozlyuk@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220119210917.765505-1-dkozlyuk@nvidia.com> References: <20220117080801.481568-1-dkozlyuk@nvidia.com> <20220119210917.765505-1-dkozlyuk@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.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: 4f416719-a6e1-4b20-4765-08d9db900441 X-MS-TrafficTypeDiagnostic: BYAPR12MB3288: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: ylv3LxWf+8OdcJ5msjAd0bby6F1tnmfv1O1P0GRfY6mE/YugSqFclSSjq0fDGUGLUD4LFXdGfFbyviW51gNpkr0xNwHxjwg3Pd8uZC3jSiMV2cMv/ZjfZyWiJ7NEZ+CGSQlUk17NubND2n4wbI6YGN0axmYcjhr8+IGc8yyFWDhBaMEaFXpA8zTdbf6ZRHiVv/I+KgnE9WDUaQ3O1XyVFbTDAxwOPY+hT9d5gGhGaTldP0Bk2dX/MW9mqugy2rT6+4CFJuQWhr6ZQaY3VVN0NN8oYsI8KRaPwQU97cm2hI0QNbeEE8DevMQarfbiiWxuixnqjYywIUmavATvvXbw1Utx8cMZ28THlEKkVFHWN1xi+TwHrTKmaypR23nawkuL0zS8h0bGxZ0vlVoYTS1q6QnUiBtfJOsw4Gdc3W03ZdS4WzIpn4pO+E8pNY/xlOV/KF7oTGdbXxkQWY/qj9ZJm5tYHHA2LgPVW5Xe41S4NG2QnXwBkci89/gG8LInyWgck3eQYc2QMVDKlq2uNje5WJEsmZorP240wbQL2WwSfF8MbbpebaJVNPXYdEvsuGlTA5bScoOeEgGfRM0ewQWl8Z6MP09clVdVKLfSJ7fXU6vbCobnKzfj5I7yBA1YQy5CL34ZtcgyTvUmGneWFUJBRJLf01/krF5EH6RQC4VHn68/t0V67sbJ5W95J/NVpB+TyDmzVD51xE1D3aC8Jz9fI2yQXGkOBz51J/NcI+LpQNlXWru4JO1pFG9ROFb7d4SOfKEO3t36+mm9RPEpAodAb62XbYHwjskJf4Y70kCex+oO1Y7Vmfhhh2hM7iVDP2iUtC3f6gih06Xzm+FB4P35ig== 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)(36840700001)(46966006)(40470700002)(7696005)(36860700001)(82310400004)(86362001)(8676002)(83380400001)(47076005)(26005)(6666004)(55016003)(8936002)(54906003)(426003)(336012)(36756003)(2906002)(2616005)(81166007)(6286002)(1076003)(70206006)(316002)(5660300002)(70586007)(356005)(16526019)(186003)(4326008)(40460700001)(508600001)(6916009)(14583001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2022 21:09:44.1546 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4f416719-a6e1-4b20-4765-08d9db900441 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: CO1NAM11FT048.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3288 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 337f2bc739..56a1ddb32b 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