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 633C0A0032; Fri, 24 Jun 2022 15:20:15 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1415F42802; Fri, 24 Jun 2022 15:20:11 +0200 (CEST) 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 E86A0400EF for ; Fri, 24 Jun 2022 15:20:06 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A5UDpPxKHmXCOU8FCK8Vh8kO3Wdy2LCTp6LtQgy7wK0rbZsfZxfWcIoYgg5sj8pjngHlY8vtWTAq2aVA35fo2y85L0XS7J1y4/3zKI5NbNZXrmqj73NsQJREEQiL1GedZZA7jxIPSNvjScZhWTkh/vNHW5Xzy8+pkY1mwEHtfKMwwEq2YTHvhADgxE8ODSp60995wv2JuLN34Qp7dswDyhNk+3hXQHrS+LtjgovqjbjXi12ZcBXJqioyOHrxT0VlEfkkniHnxYbuQoyOkV85cXo7O8zZtHxdRGLBY++Vqc7CiaisaRclD5wrm/AStV5mr80vqxW7Ky0tPfdJW0+zgA== 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=ESzomx/j21N405TFIsotT5TRyOLIxOMm8pFdZe8anKM=; b=PcQ0R8+wwXHoro6B9HL+Do8gYYqthhWZQfulFNXHNfgHd1c6SZZi895nJObZSN4lir2CvMfJERX3Ua8CBkt0QH70IwqxHq3EjZsYamUH5wgR/ys5vg937UfE1BUx0mqK1GUG6m10/h+qGQNcnUkSjZFJ+CcdanQVq7jXsNJRuOhWHISl6yBRwZpikeRSJl6gKYxpct51J+b/5mmBODZY5vxwvFiJYNlbuFXQ8Hu7c/HkNdTBjEUqYQ1XwB5iUhJliAldHXQ1v7/MDtnIqFi93KRETleFm2MhxgX0lcBTZx2vybjejuddWCe0ynS493E/TUmr/VmmDheAcdz59axnng== 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=ESzomx/j21N405TFIsotT5TRyOLIxOMm8pFdZe8anKM=; b=ZlsgRzkzNKRTHWCa/QYKIfhjUXRYzc3dGcC9FVMacnLkO4NTmrs3QElgC2n/MlSoVadUSxMpNUotUmGqMz2x2ykUTNFJZyogQQ7jSmBcrCg92HvkcK+jjsPijnJ94LADVTbZMJEkJo48bUe3tV2jYQ7ZM6nwyVQvOIgg/L8FvfAvJL0qAm9du5W0lURWU9wAg5bhOHd+FYbZaQCDRpfd5k9jCyOhbPr4XfeN2Rh3UCcmI2BCkA80fmNkSxX7j6NbhGMlpVXkvLKlFb4xencEC0Co9d9R+XBJje32Dab6dPQDUSLkcLNZCY0/szdg55pRAkWF9cEFj7sxH4VuVcPSGg== Received: from MW4PR04CA0305.namprd04.prod.outlook.com (2603:10b6:303:82::10) by DM6PR12MB3675.namprd12.prod.outlook.com (2603:10b6:5:14a::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.19; Fri, 24 Jun 2022 13:20:05 +0000 Received: from CO1NAM11FT009.eop-nam11.prod.protection.outlook.com (2603:10b6:303:82:cafe::1d) by MW4PR04CA0305.outlook.office365.com (2603:10b6:303:82::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.15 via Frontend Transport; Fri, 24 Jun 2022 13:20:04 +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; pr=C Received: from mail.nvidia.com (12.22.5.236) by CO1NAM11FT009.mail.protection.outlook.com (10.13.175.61) 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 13:20:04 +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.32; Fri, 24 Jun 2022 13:20:03 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) 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.26; Fri, 24 Jun 2022 06:20:02 -0700 Received: from nvidia.com (10.127.8.11) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.986.26 via Frontend Transport; Fri, 24 Jun 2022 06:20:01 -0700 From: Dmitry Kozlyuk To: CC: Bruce Richardson Subject: [PATCH v4 2/5] usertools: add options to change mount point owner Date: Fri, 24 Jun 2022 16:19:53 +0300 Message-ID: <20220624131956.75160-3-dkozlyuk@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220624131956.75160-1-dkozlyuk@nvidia.com> References: <20220624084817.63145-1-dkozlyuk@nvidia.com> <20220624131956.75160-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: 233ea56e-7219-42f6-13e4-08da55e44088 X-MS-TrafficTypeDiagnostic: DM6PR12MB3675:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3psajw68v/sW/MX6cpUqNWMsLtZHU08mpHqIImBH49ayaweFzky3RfvXrC9pQbtoVsTyiEKDdm+F7FaEX7lFrS0BbRqtiDErRIFuNY7RGDCM9sd/33/LbgFhVwPeBXKiDmlfO2ZFC2Kx/PLSUqgagMpqE/B1oAVCvRJGvlP0nNVf7xU9ov0K1rDI8oWNanxGkDzUrl67+KcfVryq/cGiH1ekdaHGI1WvSHliEIKwh58Pm0zLVWR3rW9ILM0NJ3zCYTvbvi4ydcO17YICT270HdEfuzlB4mGW0fMOzIpmc3ODMmNWor1ihrv6eZmHSQqCy3vXWBDdmIqrKDwHpFwg8IH0fBIIQUgvcaQv8GS/8i2wWXPjlhgDUedAczqRLnqgdJUnAVkqXriVuXnJmok3V0TjP0d3eDqR9UBAU+nXJHGK8VIs7nDICYNrH9q9dn9SQfD1XDokf8CRUH+a5Mpw1Z8kLrBJ94YE1ZKcR/Z83I3qNw08YVpqjI6RxM7yMszh9V8hpkB9IwiRnR400qFJoHi46Kpnlx99aLiayzy6cgoTnjdXqINfuB24tag2gIErVtxzOJCdPAZHXaF3no6fkbilRu4/oYSaJm0MZXEMlo0VE5/UCVw29M7FZu+zHP2Ha0/sCr+dVs27XJFL8VAgUT88xFu32f1WzT15IKZ4nKOwF/lHdzp4zwjDkvBzI6yGVlOdaSs4VX/yd8rGjOj6yEB81pEsiyh53u7IeeJHbyTYM5+X07wDHTDA7/75D6Eay3IUIykC+AV6uYNiRIF8gXq+12w9TG25kfRIAXDH2mh5c6NXe20gEubjXnwsWX1NQInQIbyLZsU1rWWHqLWk6w== X-Forefront-Antispam-Report: CIP:12.22.5.236; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230016)(4636009)(136003)(396003)(39860400002)(376002)(346002)(46966006)(36840700001)(40470700004)(86362001)(316002)(40480700001)(2616005)(426003)(478600001)(36860700001)(83380400001)(41300700001)(82740400003)(6916009)(1076003)(26005)(5660300002)(70206006)(356005)(8676002)(70586007)(336012)(8936002)(186003)(7696005)(82310400005)(81166007)(2906002)(55016003)(40460700003)(4326008)(6286002)(6666004)(36756003)(47076005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2022 13:20:04.8817 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 233ea56e-7219-42f6-13e4-08da55e44088 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: CO1NAM11FT009.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3675 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 --user/-U and --group/-G options to apply this 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 --- Option --unmount/-u was already taken. usertools/dpdk-hugepages.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/usertools/dpdk-hugepages.py b/usertools/dpdk-hugepages.py index 8bab086a2f..a22d504d3a 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, user, group): '''Mount the huge TLB file system''' if mountpoint in get_mountpoints(): print(mountpoint, "already mounted") @@ -178,6 +178,10 @@ def mount_huge(pagesize, mountpoint): cmd = "mount -t hugetlbfs" if pagesize: cmd += ' -o pagesize={}'.format(pagesize * 1024) + if user: + cmd += ' -o uid=' + user + if group: + cmd += ' -o gid=' + group cmd += ' nodev ' + mountpoint os.system(cmd) @@ -234,6 +238,16 @@ def main(): metavar='DIR', default=HUGE_MOUNT, help='mount point') + parser.add_argument( + '--user', + '-U', + metavar='UID', + help='set the mounted directory owner user') + parser.add_argument( + '--group', + '-G', + metavar='GID', + help='set the mounted directory owner group') parser.add_argument( '--node', '-n', help='select numa node to reserve pages on') parser.add_argument( @@ -279,7 +293,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.user, args.group) if args.show: show_pages() print() -- 2.25.1