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 8AC86A0548; Wed, 8 Jun 2022 01:50:13 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 776CB427EE; Wed, 8 Jun 2022 01:50:06 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2075.outbound.protection.outlook.com [40.107.94.75]) by mails.dpdk.org (Postfix) with ESMTP id B5A6241614 for ; Wed, 8 Jun 2022 01:50:04 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A+jj2lvpDVXUusg0wjHpRv1jtwg+BsfQezkTQwzR8iOEicvbTGzt/BKtQGo8z1HN6wJzg5ImlQNRkG/WNRgzo6vfHS9kNBCVSszy5NBY4D8JRLdfVc/Vo4KTGrycyXu1zpWSBMSdP5bQ+ErJWoFdbdcUsSMNCKXH7656EDDPYJ3aiTEzWpK3YKcZdgIB/2lfeOsSz6DXdXdI8IVN2wWy1Ua5YJSqImcuSyP0EWNdp4PkDBEhMbN3MazlSAY7SeJvUaf09VHfVzITnjRNuiElJxnwsKqE1srKSs5XFEc5lISQuOscsW0uA5DOCPIeKtoLLHhuzuzX8i096osWpED8ZA== 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=uj96b/6BV1/h//uVAJcGhoGDQSgxcBGsDypqqzQRx80=; b=VdC20gSViQzNk9DHHwJomR7PJbxDTtw+/Kwxtg1CJNGIx9PClPZwuoSonWrg/Bx3/0jx8a0eLqO++TODpDyNHX/+7oWvbIfjp2XVd3gDWNNRkZUgIVuCz6vU8fxt6RW6mcciJUIUk/fSXHhsY2M9w4eLJ7DOgWhkgT40CItXaxS1YyEd7Rrm4gZv6cCSne1i7wKS74F0+qhxgkrhzDdlqbleRS3h2PnTZ0skE9Aqo3zNUQGVDq8I2U96wirmDr8eWWym7D1ufEefQxw9DqFUrrgL0REZs2EBGFuA57iaURScepAUxsGjBQsfeatUYpzhOLCSvIH23SeYLooXJxmMow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.236) 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=uj96b/6BV1/h//uVAJcGhoGDQSgxcBGsDypqqzQRx80=; b=JEwhBSYZryHGV0zLsA1+PLMSAt8z/fsHcT2rUtNWviA4r3rB4FilALglH7RCArJSSueGu3h3ZtmczzoeISnoTNMgX//eVccYbdYWMsqJw70gEUtDKQQAQRP737eHGHbMOAEbEAhPfZWrjrUATlYzp1ydkzR/rQaI/OzFgKQ5hyAPq5qFdGXiLtM8deBlYbpYXAmnMAXFbG98JW7viM1+51Z/K2Q7ZVBsno1TyZAj/3B8JuYRdveUdJ0P0MsR1ya8bLXmerh/ONfFyEXZiJ/aVbVPePJ+wzgK9VBXbj/ywkxDkVMlXQbsAzVH+YtK0gu3/3Qr4ZyUI724AQUD15uAgg== Received: from DM6PR06CA0051.namprd06.prod.outlook.com (2603:10b6:5:54::28) by CH2PR12MB4808.namprd12.prod.outlook.com (2603:10b6:610:e::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.13; Tue, 7 Jun 2022 23:50:02 +0000 Received: from DM6NAM11FT051.eop-nam11.prod.protection.outlook.com (2603:10b6:5:54:cafe::d4) by DM6PR06CA0051.outlook.office365.com (2603:10b6:5:54::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.15 via Frontend Transport; Tue, 7 Jun 2022 23:50:01 +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 DM6NAM11FT051.mail.protection.outlook.com (10.13.172.243) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5332.12 via Frontend Transport; Tue, 7 Jun 2022 23:50:01 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Tue, 7 Jun 2022 23:50:01 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Tue, 7 Jun 2022 16:50:00 -0700 Received: from nvidia.com (10.127.8.11) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.22 via Frontend Transport; Tue, 7 Jun 2022 16:49:59 -0700 From: Dmitry Kozlyuk To: CC: Thomas Monjalon Subject: [PATCH 2/4] usertools: add option to change mount point owner Date: Wed, 8 Jun 2022 02:49:47 +0300 Message-ID: <20220607234949.2311884-3-dkozlyuk@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220607234949.2311884-1-dkozlyuk@nvidia.com> References: <20220607234949.2311884-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: 73ec76f2-78f2-4603-8c6f-08da48e0701a X-MS-TrafficTypeDiagnostic: CH2PR12MB4808:EE_ X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr 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: iYP8Nuwxa2dN6ZqOfxS+6x3i6MKC0FYs87tldRAtZvGDwxMyYlyS+udZNht4mb3+QUDJVqoDXDjxxkXKfv8k0IK4d0/MnZ5s085FdX+9YYRDzwzbxpAAKifzyj9XSKtOejLIOD9qr32HY0n3pOjynCDe0ZI+QmjAN4BsuMajRfrks9C9qFRt07q4rcO4n5J/0aAi7l9PwY0m28Z7zL5WcKeMcxTi8yUtDa6lekF+L8IK1CsMxMfKtoO5cGfqbtrb+CMtNDYTUORq20KjfnT1ui2zAwkhKC7l7qvTDB/k3HYatzPvomdCQmO2sDwlzoB+q92rDfBHQE5U/blRyVzOm6ODfsspctHE+6zgXsCpTCaGfNaPA6YB80X2jBGJck1S/OXlhFipTn0/lkVu9/FwQ5W44T7TISJdqclzzbvv1hoQdKDn1sAHIxbQ502h3xO3lwv7lV2lJUX7krpP6YpwNFT67iJimvl39IpZpuIQCPpFi9zfvrruv6diVApxIXeB6pxoMNDWLdB9oC4ao01zb7VZqMSiN7HPXMYTwQgcavCnk/fRONyOn6XDHHNQC3Wkb05z+rXA6ZShCF7jPO5k13qo4lKDRtwKTC/7/bzVpPWnVjrp2xHbbE/T4TUzrCI1Cv903hyRKYFYXXwoBvnuRT1AmmZF+vSiqB6m1pvYI3Z8VgZgDTUK0bO5YDXmlCnr7gT9LuH72rwK+fIBYVbeeQ== 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:(13230001)(4636009)(40470700004)(36840700001)(46966006)(86362001)(40460700003)(4326008)(5660300002)(8676002)(70586007)(70206006)(36860700001)(7696005)(356005)(1076003)(82310400005)(6286002)(316002)(6916009)(26005)(6666004)(8936002)(186003)(83380400001)(2906002)(81166007)(508600001)(36756003)(55016003)(2616005)(47076005)(336012)(426003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jun 2022 23:50:01.5758 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 73ec76f2-78f2-4603-8c6f-08da48e0701a 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: DM6NAM11FT051.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4808 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. Add --owner/-o option to set the owner after mounting. The benefit over calling chown directly after the script 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 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/usertools/dpdk-hugepages.py b/usertools/dpdk-hugepages.py index 8bab086a2f..1e01ac3d9f 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") @@ -180,6 +180,8 @@ def mount_huge(pagesize, mountpoint): cmd += ' -o pagesize={}'.format(pagesize * 1024) cmd += ' nodev ' + mountpoint os.system(cmd) + if owner: + os.system('chown {} {}'.format(owner, mountpoint)) def umount_huge(mountpoint): @@ -234,6 +236,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 +286,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