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 584E4A0032; Fri, 24 Jun 2022 10:48:41 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DBA894280C; Fri, 24 Jun 2022 10:48:35 +0200 (CEST) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2088.outbound.protection.outlook.com [40.107.243.88]) by mails.dpdk.org (Postfix) with ESMTP id 1E239427EC for ; Fri, 24 Jun 2022 10:48:33 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BX9b80dj9lsL45GJic8BsngZgs4T94SN4Q5Uiek71pMlZkq43sbhM3uI6IxobdbMlOJ5hY+VGP34YYsHqxbMBkV2wPAdL3a1nvEhnmo1zTdTrjENG6soZBgxs5cuULILVUmjWrQ8q7nzmUXHka7dHcTuwAEYlMFsK+FEsJR0GTT4DJ1ValSoWhc7THI+dDH11XH+47e5V+sbn2lPUZLDezj+kHnlnpgZo+mwy6JxfDoLSNdkUUyyTCurFVxHaH3TEcHOM+1QieVXmwLvDyGfmYOs74VgJGSJQvdJ0MszH5/xzuX91H6LYk/O3xlgbOYWA3rIF6YAjy4UVdhBL6Y35Q== 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=XsPxSBudlIj7TQgeohcPkWmix+pKgrIZHqbW0ywiTFE=; b=ajaoaX5qQh7tuhdtwUB3oeH/tuZ3/CPlyf3qmq/T3HfGUTYyO/C6O0sHSOU7STId/JcSefpEuddczhiYCdogVFXHSvwlDQnv8svX35QWOTZqchAbbHZTZzNPoftl4u89uHoULyu7ORsAURSMbTFhNyN0jUvikDW5twBdo2AvFmqFnAfAvjhyvKWAIFOXvJSdWeVCXrxuq422gZLPVx1I0tcrV+vBY4pynKUNbKrZrYC4msU+u6UQsbR70OhdQV11gVy/D8UKinHM+5+uWL6M4y43NIrcdqY2i6bl1YeD79JoEtuB8mdbd2hbOYg9Ar73z7vccdU63QPETXAmGXCQGw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) smtp.rcpttodomain=dpdk.org 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=XsPxSBudlIj7TQgeohcPkWmix+pKgrIZHqbW0ywiTFE=; b=JiiEQW4jezSp8+cUd8BWTDhQr8/haWqP9DFc5i5z0J6BmIaJ9UCzTeGDGQodoB2IdlDXSsnNcczlkQ8kKHrh8LpYhfFWwcawcOuPARs2iEGFSA3Yj2/CU7T2PBxyXd1hH2UODbMPfWqliKsm8I8vrFM6LayFSgQ+nH2nhXxB5foZm/CTjI6CAGisSVzQ7zLLzlOWvh7GASa8lVyroPLbyZk3klMCeifNicjDpx2JAUpLN2mivLSfezWy8FQrchVIYgFK2nl7nZyxKTfUu1YAwRQklsgvbJ93xr1mXTDYpculXnSvk4qMvCkH0muCz4+9omwO/jremd3ZbU58eZqkLw== Received: from DM6PR07CA0130.namprd07.prod.outlook.com (2603:10b6:5:330::22) by CH2PR12MB4280.namprd12.prod.outlook.com (2603:10b6:610:ac::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.17; Fri, 24 Jun 2022 08:48:30 +0000 Received: from DM6NAM11FT010.eop-nam11.prod.protection.outlook.com (2603:10b6:5:330:cafe::5a) by DM6PR07CA0130.outlook.office365.com (2603:10b6:5:330::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.16 via Frontend Transport; Fri, 24 Jun 2022 08:48:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) 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.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.234) by DM6NAM11FT010.mail.protection.outlook.com (10.13.172.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5373.15 via Frontend Transport; Fri, 24 Jun 2022 08:48:29 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Fri, 24 Jun 2022 08:48:28 +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.26; Fri, 24 Jun 2022 01:48:27 -0700 Received: from nvidia.com (10.127.8.11) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.26 via Frontend Transport; Fri, 24 Jun 2022 01:48:27 -0700 From: Dmitry Kozlyuk To: Subject: [PATCH v3 2/5] usertools: add option to change mount point owner Date: Fri, 24 Jun 2022 11:48:14 +0300 Message-ID: <20220624084817.63145-3-dkozlyuk@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220624084817.63145-1-dkozlyuk@nvidia.com> References: <20220617112508.3823291-1-dkozlyuk@nvidia.com> <20220624084817.63145-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: c9b40b93-1034-4c30-b6ed-08da55be4fcb X-MS-TrafficTypeDiagnostic: CH2PR12MB4280:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dNYhQqGUefeIwWmdTCsd5wg24b2YxMCMi2EuhwRZl3zpbVgRAF1tLvNv6R39q5WpAy1E+vu9Lk4DSdmLn7HUr7RSynwdplXpEp7wD83spZ90NMKlmrZsWzkhryRibkOvFoG2Ro3INf8TzYIatLZ37TIf7LXGthlaWd4We54HHVWcnGIgtIejULMwAntWk+UpWuQ/ZaukqdP2d3kPvAaCC2nYVR3HZ0jo/DKUjUJkt2u9aYNDoQS9k276fGosakE7Vn2iAehs7908jVYKqmz6bc6JKxBiuwALz0T+tdW0/D/UqDinDVZr7MC0sgugLeNmaM5lq1Kbje67GPrANSb0j9ErKawF01Vvp5IIVjmRhPlmv9PKd3ssyzBrQAZKsOx3Ga6Ll3VUIkykY15zu2qSfHE4Xgf2kntzGDz+D4M5vBaPXfcZxGP0bo5Uhb5uxAw1PlXigusURsS4wY9bJiwKKHLugSrQ6K9TqME6N4N2nLEoSeEk3elBwxvEts6H1gKKETnxcXRo5gV1qR0PuD61kiRymamHN3sCU0WrwfwSTwYWkJC3eCSfnWitqTAKQodoVMWkRdX5E4UCznlNuXTVVilgTCOD6W8+foRfmDajptm1B2tCWe7ceQ4syM0NPAfMmqlAF2EQOeKxU/cdyGK/AwV3yrXcZwFjnsu2eTefVOEdoNRiKCudmuNdNtwQIA4ouyqq6PMrRWYXKDV99v9mKT8D3kpzsN0pRc/WdjXdGT6wMk1NOH0fRDoRBnb1JuZAVh5qBNhOpP2aOKAAPvEFEOkf53FBrgiAz8ROYra7lriPldpaqF3dshItl8Ui4wNURMTj5vPl0gWnVs33ZVAkWQ== X-Forefront-Antispam-Report: CIP:12.22.5.234; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230016)(4636009)(396003)(346002)(376002)(136003)(39860400002)(40470700004)(36840700001)(46966006)(83380400001)(47076005)(426003)(336012)(41300700001)(1076003)(2616005)(186003)(81166007)(82740400003)(356005)(36860700001)(5660300002)(8936002)(82310400005)(55016003)(40480700001)(2906002)(26005)(478600001)(7696005)(40460700003)(70206006)(316002)(70586007)(6286002)(6916009)(6666004)(86362001)(36756003)(8676002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2022 08:48:29.5994 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c9b40b93-1034-4c30-b6ed-08da55be4fcb 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.234]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT010.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4280 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 Per mount(8), the previous owner and mode of the mount point become invisible as long as this filesystem remains mounted. Because dpdk-hugepages.py must be run as root, the new owner would be root. This is undesirable if the hugepage directory is being set up by the administrator for an unprivileged user. HugeTLB filesystem has options to set the mount point owner. Add --owner/-o option to apply this option when mounting. The benefit of performing this in dpdk-hugepages.py is that the user does not need to care about this detail of mount command operation. Signed-off-by: Dmitry Kozlyuk --- usertools/dpdk-hugepages.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/usertools/dpdk-hugepages.py b/usertools/dpdk-hugepages.py index 8bab086a2f..5120518bcb 100755 --- a/usertools/dpdk-hugepages.py +++ b/usertools/dpdk-hugepages.py @@ -170,7 +170,7 @@ def get_mountpoints(): return mounted -def mount_huge(pagesize, mountpoint): +def mount_huge(pagesize, mountpoint, owner): '''Mount the huge TLB file system''' if mountpoint in get_mountpoints(): print(mountpoint, "already mounted") @@ -178,6 +178,9 @@ def mount_huge(pagesize, mountpoint): cmd = "mount -t hugetlbfs" if pagesize: cmd += ' -o pagesize={}'.format(pagesize * 1024) + if owner: + uid, gid = owner.split(':', maxsplit=1) + cmd += ' -o uid={},gid={}'.format(uid, gid) cmd += ' nodev ' + mountpoint os.system(cmd) @@ -234,6 +237,11 @@ def main(): metavar='DIR', default=HUGE_MOUNT, help='mount point') + parser.add_argument( + '--owner', + '-o', + metavar='USER:GROUP', + help='change the mounted directory owner') parser.add_argument( '--node', '-n', help='select numa node to reserve pages on') parser.add_argument( @@ -279,7 +287,7 @@ def main(): reserve_pages( int(reserve_kb / pagesize_kb), pagesize_kb, node=args.node) if args.mount: - mount_huge(pagesize_kb, args.directory) + mount_huge(pagesize_kb, args.directory, args.owner) if args.show: show_pages() print() -- 2.25.1