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 1E5ECA0093; Fri, 17 Jun 2022 13:25:32 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 549514280E; Fri, 17 Jun 2022 13:25:23 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2057.outbound.protection.outlook.com [40.107.236.57]) by mails.dpdk.org (Postfix) with ESMTP id 3952240698 for ; Fri, 17 Jun 2022 13:25:20 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kyecKZOdFCO3yILxBlZd7zz0BGf4kXIZ3j7pIQwBCwYDXBOOYHlR+eqBKeCFBI0xPhoBo09r1U+mP/JJVV/7NhAwbaH7seZUyJ0tHuLezlLiRSEGW055X4j2o8whbuAUxQxWuox0QSLYH7p4YVPy58MQwVOqYz99A9JUzyVX7nhldKTpx40fZVg2zmRdywbKZ6w6HF+4Whh/vXZztuvMJo3bpTVVawoHsJUwPNncWEfTLCMySV1d6RK0Tiz6PwEqScPhnnwHLBTgXXx2RccVtmRGxPKxwUjSDiDdYNstwJ1lX11ZyzOWVNwcDqR/08PWt7zuv6ruZp+sDKJ8IXhgOQ== 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=dwL5abDJMEBsRvTtMqGhBVK52vDqtJxAfQc8R86d/LN9eCZt4c1aTJDCglrdZv71aKkf8W53QdU7OMu/TqxDWT92EMjJbTGrFtOM1jbh+YKVXoRjdOk8UqL2aTI/5c+olU+pwWm2bDfFnAe+rQ2idZaMNBlBKrikdrWrV4sVo7kg5zuseQsFyw1RyjJuhTXs4iml6kkOIwH9oaUkfytpqKueHqwVjmdrKxp8oG805HNpBzQ8ZHKtK17z+Fa4RwWS+m95HBjDmWyfWMO1hr9Zq/KQDqeEDEYj+ILYrY5qGwoFObNm2GmmgOrE8p1UNojw7vb4zabmolMzObYTMReeFQ== 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=hchG5Brr19R2cQHAI6N7/WQ0u4qox0ADavHSWmff3lqXb7sfSiGGMh8FuKMH80s9ToZQOfs6Wc0XAkLiK+o8zT62NkAzf2oDogLvzOr3ncoCmvdnIvPJDpreGjuLya2PM8nh6lB7lNhzj63JkBN08U3nt0g9MFhldmm4nLy7NiwcOY4W7SxjyIf73TBcGg9AT6P0RgLb0pqkjBuFuHNkwV1e27kdLpOLlkxhxBKVJUaDPkDMvdpeJB490/hnGthk0oR32mOBmh8IFmr6eCJsJWE0OCMXtik3nKV+uaTKas5lKG+ZjbOig//Ad8zuFDSuY/HKGEvTljSeYYAKknMGcA== Received: from MW4PR04CA0242.namprd04.prod.outlook.com (2603:10b6:303:88::7) by DM4PR12MB5746.namprd12.prod.outlook.com (2603:10b6:8:5d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.18; Fri, 17 Jun 2022 11:25:18 +0000 Received: from CO1NAM11FT032.eop-nam11.prod.protection.outlook.com (2603:10b6:303:88:cafe::a8) by MW4PR04CA0242.outlook.office365.com (2603:10b6:303:88::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.14 via Frontend Transport; Fri, 17 Jun 2022 11:25:18 +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 CO1NAM11FT032.mail.protection.outlook.com (10.13.174.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5353.14 via Frontend Transport; Fri, 17 Jun 2022 11:25:17 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Fri, 17 Jun 2022 11:25:17 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Fri, 17 Jun 2022 04:25:16 -0700 Received: from nvidia.com (10.127.8.11) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.22 via Frontend Transport; Fri, 17 Jun 2022 04:25:15 -0700 From: Dmitry Kozlyuk To: Subject: [PATCH v2 2/4] usertools: add option to change mount point owner Date: Fri, 17 Jun 2022 14:25:06 +0300 Message-ID: <20220617112508.3823291-3-dkozlyuk@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220617112508.3823291-1-dkozlyuk@nvidia.com> References: <20220607234949.2311884-1-dkozlyuk@nvidia.com> <20220617112508.3823291-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: ff311096-e314-41fd-51fa-08da50540e8e X-MS-TrafficTypeDiagnostic: DM4PR12MB5746:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 47vsUHcIrogJKau3wNoKUwWvHgic5xyrPV21ApBkmqvi8oPNAW9amodUW3VfVeqF5IyJi/1GRiNDbqE6FFL4PhLJRjhC4MCiCSl8J4DAPtTfT6dT9WRGBjkB229ktMzsCsw1x04Uas/DewQ2MFn37JlXInf48+7lrYHX0sAaSka0hkvUqcz1wjNKcKa2xKaXBJj3utpu+g6F0UR3/K7yut4XAPWjPPQxeCOEQ58iZMjN5EpR5YThMx0QjjTz9uwq19OtapVd8ThDnR9cfYqM+vWUBtecfpTiqWH4MtlKjUq38r1KdnglQds+rEL4UXXK/BuO45YG43V9Yz090L0fNWRKPy+F1QpZaZADiryhQ86hOrwnWaUYgPF/42zq4UoN6RnD1h01ec71OrQfj7gCEgpL60zQEWqywiN85QO4PbVUYYuxOWdx5AcB/+3ziooniLN7aUpREM0AF5dzUlKOEsp791ggEDDjiWUxCvnOvwAg7+tyl+bdwSQU45fHiUX/4rfl9QEl8EFS62uR2WyCRR6xpofRKnhOHj4HfN8Z9AHDYQm5p8yX5+2yxB845LzfrGtqPvLKGkqkzPm5F5R5XjCOYDqACu5TRfKSLXu07jgz+szlasXOSO15H7DBp8h0EJdSOPT64noitsmQwkWx9uO/wE5ZTiamtG+0mdeqP1+OUqQXT9KH4gtxaLzqGg0d6p42ic3McqC7Uf7ln53ftg== 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)(40470700004)(36840700001)(46966006)(83380400001)(186003)(426003)(8676002)(336012)(40460700003)(7696005)(1076003)(55016003)(70586007)(70206006)(356005)(86362001)(8936002)(47076005)(6916009)(2616005)(498600001)(6666004)(82310400005)(5660300002)(81166007)(36756003)(36860700001)(26005)(6286002)(316002)(2906002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2022 11:25:17.6779 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ff311096-e314-41fd-51fa-08da50540e8e 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: CO1NAM11FT032.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5746 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