Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp84684pxb; Wed, 6 Oct 2021 00:02:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOEBUHEZWpYCNkSoplHCsfaGNwGJpjBZde54IO3H+DuGdQMzLoPLunHuXq5FS+qNcqEUL2 X-Received: by 2002:a05:6402:1914:: with SMTP id e20mr3568539edz.304.1633503778316; Wed, 06 Oct 2021 00:02:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1633503778; cv=pass; d=google.com; s=arc-20160816; b=xk6u4x5/jeE4vBtaH/dGDOW5AmRRm5CajPaoyzTKykbem+xByPBWOQyXeRtzNQJeKm nn2EnsHw9sPsW6mHHYouOXHRFfFz2l5HdX9ddzB5V643RPqx1Q8ERToOa7XuzULsOAGS ddXRa3dfNZD7rifnGpDL1+1HlqyzDFQD6Num1eYx8llAKeaZGoC7aezVGE4TChKA15Z/ BwJ5CF6CQtHtvBSxavTr1odLpW9uRFrkT+rWyTOL33KtF34sjS+bxG2aHMYvLPs9cXXY iHcAZadpMpKyZyUiAo2RFTDUMrXXxoU7VZX8eFIMaiIMT33GC9nb5bOSx+sPGPaKqQed RT7w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=5tZP5Yy+bc1C0LdPnCi1kwsMyjPBwX7RnaE/mghBbyA=; b=Q63QcmLlfxmXZJGYpoyr/pQ5cDXJEs/xRTuzCxyi5K499Zijkj20GfQ14zv93hY4+7 +7ULQgY6cWhqaVUunPYmh3bbXDj2QAsQUn2PBU4FaZ7DNCv6DoEgg03lm45INTS1Ztca wgcR8rJ8xBTbkFD05hFf0AzeHn8Itmz6DAZV/2ebKXrwFl+1lixH2js+XmtB5Er/is1L +c2hSPYnetafsBRyRYRBfyiRFsxE4TnEipXGLo5I4CjmqXzqQvt1vaNVUUAz4ycTETXV ArYOQK5dVZnRMVUPrqcynGGDm/qw08WV0UhH+6w9k79qKYLe9st7y1YHOprgmrReKDqK QB1g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b="b/Y3a+O8"; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f12si2535647ejx.695.2021.10.06.00.02.14; Wed, 06 Oct 2021 00:02:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b="b/Y3a+O8"; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237372AbhJFG7g (ORCPT + 99 others); Wed, 6 Oct 2021 02:59:36 -0400 Received: from mail-bn8nam12on2083.outbound.protection.outlook.com ([40.107.237.83]:37153 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S237213AbhJFG7f (ORCPT ); Wed, 6 Oct 2021 02:59:35 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N7r6wQSySwYCW8gyGYiKlySx3qk3bH5p5re5XHKT+y8eyXHhlzEVlZ3dlQQcdueErgx7O2szGZkEXq/QZ/+MkVrp/9ePvUXRtQgFFn9F3Bs9lKxMcLeFLNBNU16yD1TQHhubJidR9VzaXuare23chtLVkmLs4cutkqjwNp1q0D9SI9kdTP+ZE1R8P2DGBq8ZGI6WShauC+mWS3MZeu70r0fW3cR3h28eaUKWriaxGz+LdfuLP9K1bXU6nZq+tW8vqKcNTFmxU/g6X2CqqH1oGQN2X9DwJ211zz007WfuvjO12GLOY6xSMRfpsDfgCwIjiBLkrU5E21EYe5NVbrMNFA== 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=5tZP5Yy+bc1C0LdPnCi1kwsMyjPBwX7RnaE/mghBbyA=; b=LTC6nZS0RNtbu+0kxn5cni9cFKOY0DUVHHHUjaC33QZE+r3CywmKe5dWt0m28cfvmpONVsUUAXmnM0/GVe+BsvJS05Hco/tcRcHWQdwCm8rVaRNMZ5q1vmcMrXRhFkZkMziBEOfdCToJm3MF1IMDLGjgat2oDQS04muMvug3VvypNKXnhCngJCdqNhFvdLe1SX5ls5C5I9Y++7CClt+YhXu77U9wIA3w4hsJdMtidmJgbuP3oS4yLtKU5qbpDYlxD7bF0RyOPVRoHv5JVxbnQjXzBmQRrp2j8vLg8EDuZWRa6YL8SNlemQtpYMyFkF/dYjmyNHyPRtZOnVQJbgNLjQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; 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=5tZP5Yy+bc1C0LdPnCi1kwsMyjPBwX7RnaE/mghBbyA=; b=b/Y3a+O8+W8n/ujBfpihX5NliXmTSA8GNxxxJN+2Pck7K1k7yZrD7tLNyopAyvJkhGyaLRIvuEdrYkj2sa562wIXguT2S8wdieaKMm7YGJxp11Ks7PlQc8PAhRPP9TDGp0aOBCjpixatvyOWaJ1MJuuB2/YALYtzoDlP37CptTUUufpyA1XXZeZxp9qwmi0z7TyaM5YSzbl1sKATuA6a3E4cmzp3lpBeG/dYBXpLl6hwy8GMaMed96AqRY5qwDYLb709qMsNucdvFD2ZDeANhAuJp47PDRAtph2tqZmEHM5XdDcc+Kh31tfbg25j9OKYfftLwimWvZo1j4+c9xMG8w== Received: from BY5PR12MB4130.namprd12.prod.outlook.com (2603:10b6:a03:20b::16) by BY5PR12MB3892.namprd12.prod.outlook.com (2603:10b6:a03:1a2::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.22; Wed, 6 Oct 2021 06:57:38 +0000 Received: from BY5PR12MB4130.namprd12.prod.outlook.com ([fe80::a0ac:922f:1e42:f310]) by BY5PR12MB4130.namprd12.prod.outlook.com ([fe80::a0ac:922f:1e42:f310%3]) with mapi id 15.20.4566.023; Wed, 6 Oct 2021 06:57:38 +0000 Message-ID: Date: Tue, 5 Oct 2021 23:57:36 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.2 Subject: Re: [PATCH v10 3/3] mm: add anonymous vma name refcounting Content-Language: en-US To: Suren Baghdasaryan , Pavel Machek Cc: Andrew Morton , Colin Cross , Sumit Semwal , Michal Hocko , Dave Hansen , Kees Cook , Matthew Wilcox , "Kirill A . Shutemov" , Vlastimil Babka , Johannes Weiner , Jonathan Corbet , Al Viro , Randy Dunlap , Kalesh Singh , Peter Xu , rppt@kernel.org, Peter Zijlstra , Catalin Marinas , vincenzo.frascino@arm.com, =?UTF-8?B?Q2hpbndlbiBDaGFuZyAo5by16Yym5paHKQ==?= , Axel Rasmussen , Andrea Arcangeli , Jann Horn , apopple@nvidia.com, Yu Zhao , Will Deacon , fenghua.yu@intel.com, thunder.leizhen@huawei.com, Hugh Dickins , feng.tang@intel.com, Jason Gunthorpe , Roman Gushchin , Thomas Gleixner , krisman@collabora.com, chris.hyser@oracle.com, Peter Collingbourne , "Eric W. Biederman" , Jens Axboe , legion@kernel.org, Rolf Eike Beer , Cyrill Gorcunov , Muchun Song , Viresh Kumar , Thomas Cedeno , sashal@kernel.org, cxfcosmos@gmail.com, Rasmus Villemoes , LKML , linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm , kernel-team References: <20211001205657.815551-1-surenb@google.com> <20211001205657.815551-3-surenb@google.com> <20211005184211.GA19804@duo.ucw.cz> <20211005200411.GB19804@duo.ucw.cz> From: John Hubbard In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: SJ0PR03CA0212.namprd03.prod.outlook.com (2603:10b6:a03:39f::7) To BY5PR12MB4130.namprd12.prod.outlook.com (2603:10b6:a03:20b::16) MIME-Version: 1.0 Received: from [10.2.57.28] (216.228.112.21) by SJ0PR03CA0212.namprd03.prod.outlook.com (2603:10b6:a03:39f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18 via Frontend Transport; Wed, 6 Oct 2021 06:57:37 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: db3033f1-2932-4aec-3942-08d988969539 X-MS-TrafficTypeDiagnostic: BY5PR12MB3892: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zkXlt9oOHCmQ8o1RZJNMYjPrKwqI+6tdnNKuSpT4/mVGYDtoYROUJ6JfpLmwH/jTFNEFgLv05Gv4Xu6tgAfTAlweMD7p4MSxB1xLy4nMvsfEm0uEHNe+ylR+at1cbAOT2gxB3YqYmIpspfWPFw+1Mcv0kruJn8gl8VOFfnuMSq/Q4RgXqaMiUKA9ebmqE7T0K8kWaeFXvjY7HQ7oOwTSHC1XOZE5p5UWZ4pCCMOhzKIGNcTFBRWn3yTFEcMOZ49egQbpUngsjKfOWvGjLgwhZjdH+x0sMYnizsBGNDK0Jc/7MtQ1ILSxO2wsom7PBFCEjNXw1ethBPmlOVx/1WR9/ERkHlA7yvVRmoLx1SJiQqMjKQ3Xi6PzxqxRls75Tfph1ajlEGUjgriqgi/p2N/juUQRh0Lat2odBmJ6bBPsTdj5nSwOnCzTtmmt4Wdb6oI5q600mJ68uenaE8RwMxmWRAvZOtbR+9zUgOqLRo5gyBqDcqfDLIINUS56QX5pm8HFyBONE2fq3ow3R3RHZuXLnSz2o33xTsRfoSXnUCDaj9qRnATal0uRc64H7EbpZb1viH1S7Ta4awWOz3AYeV5jDkQ8qlBQaUl5TVZ+tc6SuP57CqY/WXfRYQuIkJONDvteKUL2c+YkuZB55hoGP9Kr9gAds9dMoumgxxKEcLoN9Cbwcwimii73B2BPigbpPyFQxgB5xSAPkLJZQgoJ1PYAiSjBRfzhPTXghZBZu2BM7PgJOHwevzRGJSI1kccNAW7Z X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR12MB4130.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(508600001)(2616005)(186003)(5660300002)(26005)(31696002)(956004)(4326008)(8676002)(16576012)(83380400001)(316002)(66556008)(66476007)(66946007)(8936002)(31686004)(6486002)(7406005)(7366002)(7416002)(38100700002)(54906003)(110136005)(36756003)(2906002)(53546011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8?B?cjRTaGlNcHE1NzZQdzNOZURpZkF2SU1nYzNRUjRPdTdKMHhXTytqeXlSMFE5?= =?utf-8?Q?6ha06RKiMEopbMh/D9kDDcPO1i0xqW22rGFu7vQ?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: db3033f1-2932-4aec-3942-08d988969539 X-MS-Exchange-CrossTenant-AuthSource: BY5PR12MB4130.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2021 06:57:38.2779 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2VI1xVoW1Z1h7k9WiXdDRTt8OhSk5fIz5ynHqHijzQssadlQgwz/+EDdJkFBZj4FOnT6yTtr8hyrZKcYaGHVJQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB3892 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/5/21 13:43, Suren Baghdasaryan wrote: > On Tue, Oct 5, 2021 at 1:04 PM Pavel Machek wrote: >> >> Hi! >> >>>> On Fri 2021-10-01 13:56:57, Suren Baghdasaryan wrote: >>>>> While forking a process with high number (64K) of named anonymous vmas the >>>>> overhead caused by strdup() is noticeable. Experiments with ARM64 >>>> Android >>>> >>>> I still believe you should simply use numbers and do the >>>> numbers->strings mapping in userspace. We should not need to optimize >>>> strdups in kernel... >>> >>> Here are complications with mapping numbers to strings in the userspace: >>> Approach 1: hardcode number->string in some header file and let all >>> tools use that mapping. The issue is that whenever that mapping >>> changes all the tools that are using it (including 3rd party ones) >>> have to be rebuilt. This is not really maintainable since we don't >>> control 3rd party tools and even for the ones we control, it will be a >>> maintenance issue figuring out which version of the tool used which >>> header file. >> >> 1a) Just put it into a file in /etc... Similar to header file but >> easier... >> >>> Approach 2: have a centralized facility (a process or a DB) >>> maintaining number->string mapping. This would require an additional >>> request to this facility whenever we want to make a number->string >>> conversion. Moreover, when we want to name a VMA, we would have to >> >> I see it complicates userspace. But that's better than complicating >> kernel, and I don't know what limits on strings you plan, but >> considering you'll be outputing the strings in /proc... someone is >> going to get confused with parsing. > > I'm not a fan of complicating kernel but the proposed approach seems > simple enough to me. Again this is subjective, so I can't really have > a good argument here. Maybe, as Andrew suggested, I should keep it > under a separate config so that whoever does not care about this > feature pays no price for it? For what it's worth, I've been watching this feature proposal evolve, and a couple of things are starting to become clear. These are of course judgment calls, though, so even though I'm writing them as "facts", please read them as merely "one developer's opinion and preference": 1) Yes, just leave the strings in the kernel, that's simple and it works, and the alternatives don't really help your case nearly enough. The kernel changes at a different rate than distros and user space, and keeping number->string mappings updated and correct is just basically hopeless. And you've beaten down the perf problems with kref, so it's fine. 2) At the same time, this feature is Just Not Needed! ...usually. So the config option seems absolutely appropriate. Even Pavel here will probably be content with the above mix, I expect. :) thanks, -- John Hubbard NVIDIA