From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5698C433EF for ; Tue, 5 Oct 2021 19:15:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6F88061372 for ; Tue, 5 Oct 2021 19:15:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6F88061372 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id A056E6B006C; Tue, 5 Oct 2021 15:15:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9B4D26B0071; Tue, 5 Oct 2021 15:15:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 87CBF900002; Tue, 5 Oct 2021 15:15:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0210.hostedemail.com [216.40.44.210]) by kanga.kvack.org (Postfix) with ESMTP id 793416B006C for ; Tue, 5 Oct 2021 15:15:12 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 2E6472D38A for ; Tue, 5 Oct 2021 19:15:12 +0000 (UTC) X-FDA: 78663336864.25.255A025 Received: from mail-yb1-f177.google.com (mail-yb1-f177.google.com [209.85.219.177]) by imf01.hostedemail.com (Postfix) with ESMTP id D79075073440 for ; Tue, 5 Oct 2021 19:15:11 +0000 (UTC) Received: by mail-yb1-f177.google.com with SMTP id s4so29958ybs.8 for ; Tue, 05 Oct 2021 12:15:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Y/mJ1wrJl0e2S4EbithBXePxqkT5yOeu8iCmqxY+6zM=; b=M1kis41L+W8a3X4xSlCWbuPFyHGcq4qAALLCMn7eMkW+D55940o+GnlKZhYo7SfEFf eKx6U0ezgxMJKf89ERCwNbfcEjqSrgI8bXetehSKbTq3hBALUwCIZPjkpgB+cjunVdCS WUOM7tVLgucnzyc8N7gK6PqKOxIpKi31m9jpvL6Suhi3ntBbP04Ksv5mHZBiqQ5gDMuB mlnsP6U61UcL/L4VlXu/rhMogaYmgD7B9TYlwJp7ET39MVF2lwNWW/NYA9HVlvbQWWyg +U9pskA/P247x4+EuPoUg8wGV/hMoaBW2hCKqC5njS/cSZCbY21y0BxIUGtwBZcfJF1H 84mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Y/mJ1wrJl0e2S4EbithBXePxqkT5yOeu8iCmqxY+6zM=; b=MZhPaZRS0wRN6/dcXAgIwISc58PJitMRVeJ+JYnTAigDd0PkrUbtw5RlkHVAzK2m/v xY9QP0E716Myp34cckC9ffondl+gcSBCH37r1F5MJCzJtvNd+yQ7b0wHcEEhN3yrOOeR CZKazQGT91A5qYhL3mq0pjbt2axhz5A40HkirS3fLeW071ICic7xQj/D0MrY8Qv+SZ7a slrTTyNQ5fICMYr/QSGuITu4oKWhaRblx8aRjJeMwsHoaPkILp6TGfl/yyh43HmyGlli o3a1cJU94AZb0qz4aTfts5ESM3QesmNEECCnPYGCHnbtXCoIx+4fabLSNjIr5XXxrLsz S9mg== X-Gm-Message-State: AOAM530J/mvVjQL262uRUUjd0GRZ/QhNAs9/cBXH1ZX1q8Si/pIkvahk kLy2HQ2dPwcNUac7VteWh669p7NoX0pQ/Hvkz/UHfA== X-Google-Smtp-Source: ABdhPJxa45KExZ/7k/RCApHcxypXu8XAAvYJq3w4XtzePMFBwOXwgWrUVZ+OKZLOGNg4W5UYgNh720duxvdX3NBhPKs= X-Received: by 2002:a25:5646:: with SMTP id k67mr25382729ybb.127.1633461310475; Tue, 05 Oct 2021 12:15:10 -0700 (PDT) MIME-Version: 1.0 References: <20211001205657.815551-1-surenb@google.com> <20211001205657.815551-3-surenb@google.com> <20211005184211.GA19804@duo.ucw.cz> In-Reply-To: <20211005184211.GA19804@duo.ucw.cz> From: Suren Baghdasaryan Date: Tue, 5 Oct 2021 12:14:59 -0700 Message-ID: Subject: Re: [PATCH v10 3/3] mm: add anonymous vma name refcounting To: 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, John Hubbard , 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 Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: D79075073440 X-Stat-Signature: oapr7qqqdkge1ume69ddg6eoa56mzjug Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=M1kis41L; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf01.hostedemail.com: domain of surenb@google.com designates 209.85.219.177 as permitted sender) smtp.mailfrom=surenb@google.com X-HE-Tag: 1633461311-346024 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Oct 5, 2021 at 11:42 AM Pavel Machek wrote: > > 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. 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 register a new VMA name in that facility or check that one already exists and get its ID. So each prctl() call to name a VMA will be preceded by such a request (IPC call), maybe with some optimizations to cache already known number->string pairs. This would be quite expensive performance-wise. Additional issue with this approach is that this mapping will have to be persistent to handle a case when the facility crashes and has to be restored. As I said before, it complicates userspace quite a bit. Is that a good enough reason to store the names in the kernel and pay a little more memory for that? IMHO yes, but I might be wrong. Thanks, Suren. > > Best regards, > Pavel > -- > http://www.livejournal.com/~pavelmachek > > -- > To unsubscribe from this group and stop receiving emails from it, send an email to kernel-team+unsubscribe@android.com.