Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp4876430pxb; Tue, 5 Oct 2021 12:16:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykcf/jRtytMnOwsP+Ly+DcChRh+jrNAyseqshxT5GsZK5uq7K2bg+o/hViIGN3tfWpAAEo X-Received: by 2002:a17:907:869e:: with SMTP id qa30mr27359257ejc.249.1633461417850; Tue, 05 Oct 2021 12:16:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633461417; cv=none; d=google.com; s=arc-20160816; b=lwCtmGqLw0mbNTpCl+Bo3aJ1OQaRaFln2+Ki3GKMnU3w1oI5vVRl3JbF59svxItOO/ dZZmdCNVGPSfPvWuwxIi1SIgMF+cjP983vEmkAQEBHE/WJJCJtkWmAp6n2LjxjD89xtO 1ko/y4XQGh/xkZkOTfRtbwmLfGfywnb2ywSZtpaagS1cdDN1npfo6Kwj5eeKdCO5EaxV 4sI+Tdglr/1vhawS4SJFDfxjnMi4c93LTLuT5e9Oy1fvQHQaBon1cKkLfX9hJgpOxZJ7 Bttf91jLpH0H4kL/jGtvYzP3gih474hpLKWq8JHG1b5C4DSm1PGaMDq16Sen0SbP/4T4 7kVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Y/mJ1wrJl0e2S4EbithBXePxqkT5yOeu8iCmqxY+6zM=; b=j4vXEGy6Bfkl/vPVsVegG1XcYx79dIEMOC3g32VKef2cHQisrvwSMrviJkJN0VOf52 hJ3FubL7N6bOO7JgZhGJVNOrr0EIrbr31xz8ZIffS2e0tkUb6ejD7dWu6mxc4QKRPwFY TrmVdo9DLCg/r/SkCp+hFEA8PjhIf0Twi0BbugaUZB/jyvBf3YdoOpJB75FW+X7Wvmj9 oe4IplpdqHrDueUG30JywytzupGCUl5giahMmEAfUoxVThtA4So77bLTLm/Wo7viUgGl zOX2CjN2Wm58B8j05rEUeo0/PO7qOotIGNQ1s8pdr1h+mZu0lBUp/cBqW0xLspWjV7A7 FQwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=M1kis41L; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u4si25434786ejt.81.2021.10.05.12.16.33; Tue, 05 Oct 2021 12:16:57 -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=@google.com header.s=20210112 header.b=M1kis41L; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229758AbhJETRE (ORCPT + 99 others); Tue, 5 Oct 2021 15:17:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234762AbhJETRD (ORCPT ); Tue, 5 Oct 2021 15:17:03 -0400 Received: from mail-yb1-xb2e.google.com (mail-yb1-xb2e.google.com [IPv6:2607:f8b0:4864:20::b2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC70BC061753 for ; Tue, 5 Oct 2021 12:15:11 -0700 (PDT) Received: by mail-yb1-xb2e.google.com with SMTP id z5so99107ybj.2 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=jpaaQiYii3vwQGhtIP8sgeGEsw081dY/5CdodS4ohZuDZWlfclt0HXsM5Fl7PKKqj6 DGTlRFB1Rk8lUPMhYCBdK+RyB36vq/3Cj3ZqIyRz/yla0Dm/jSdJWuTcyqCgEQEHyyrL zaOp4h6gXgZ8Z/w7ZI+JC1kVQ5lNshdqfzDLEW2QOKH7KtbZm1kLOzmJrBARCZkYFTSZ rxkJIocvyQXkr+FcxPhnAiIy78wNMXXq76uT7UdDONIYpCBtktgjvh4HMEMvsG7cpYNu IxhLnJAy9rIHy2Q2uF9L5zgn3lsdvnRacbpEe2OFxl1A87E07lgE+5am8DFqaF42/932 dp3A== X-Gm-Message-State: AOAM532OvKWUaWXPE0hFDM+VZdPCman+sPDdfeGJG96vl2fcyUEliOEM kQwFN5iWKqn+MgvJCJx/mZsrz51Jtl3McKkS2f0BXg== 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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.