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 60150C433FE for ; Fri, 1 Oct 2021 16:34:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DA634619F5 for ; Fri, 1 Oct 2021 16:34:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DA634619F5 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 33CAB940116; Fri, 1 Oct 2021 12:34:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2C5C89400E4; Fri, 1 Oct 2021 12:34:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 118A2940116; Fri, 1 Oct 2021 12:34:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0071.hostedemail.com [216.40.44.71]) by kanga.kvack.org (Postfix) with ESMTP id F37009400E4 for ; Fri, 1 Oct 2021 12:34:20 -0400 (EDT) Received: from smtpin38.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id A2CC6180445ED for ; Fri, 1 Oct 2021 16:34:20 +0000 (UTC) X-FDA: 78648416280.38.D05DE9C Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) by imf22.hostedemail.com (Postfix) with ESMTP id 5C6362343 for ; Fri, 1 Oct 2021 16:34:20 +0000 (UTC) Received: by mail-yb1-f178.google.com with SMTP id r4so21781368ybp.4 for ; Fri, 01 Oct 2021 09:34:20 -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=Ng6JDVwxCaQ8Od84ybUMD2tq3euaLTCb3M9qHCPLiRk=; b=pWMrJuJhvcJ8kr7fX2piDmdGOeTPIu6T7Ho6tdDljq/6BkXtPtkfuXNxbt+VAqT0yx qxH/KnQhNeeeJUh0T0GkC6QwHIxhqylRWcgJyXMU+D6CEa1A2xn3JkoGhw6s1Gc+6MsL ldOkQXXl1f/J28Sh7R0D3OzTkx/zoHPdUWAcXgmv7vIlZJmvWyWWLCtMASYrqv0cHOIu xCiqq/L6s1VtjDKAFFZ4nN/n1H5YNknX/iIT7eaOoy5vqUnPIkcIofbg2CwaVcWRlIgh eIrXGyMuXaA4shxX3MN9QTuMdzpFe/4ddYSukhdrsyyKn3FJSo2U9wi3edKON9VPPnaw zZog== 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=Ng6JDVwxCaQ8Od84ybUMD2tq3euaLTCb3M9qHCPLiRk=; b=Sh16P/fKkJZ1JvY4FTlFe1FZ9b4XdoKGGGUQB/MFTFauMZdLckRnen0Zpgokw6NiKh 1QBN8IDlqBjhDbE7DRHjW345ER9eZ4Nn8TBm+druAhslMZkw8zrDh86mfSlsqi9T3E+5 37RUPonFlYfzvUOrxZ5xBlorRvLRhivV22R7P6XAB+VywRsBjWuCyja9KbpIjmFISEqh ktr4dGn1Lcd5b3/xhrUxPr1vcwvj10tSb19bR+/m/qRM+P92Rhb1a3BrWf0buOL0AOKl +oqsGz6Oci4sJWQrXsheVeFfoZW+JP/txPnAgfM2Q63jK4CLA6Fs19BzgFpVNh4CU0CG 9wfw== X-Gm-Message-State: AOAM533UJrUMGkzNoXWtTXWOyPdOpUU91clpQvKXHeJ7m6u43GEqmP0W p1N2K3pQv+Zk4SCMdHqwSe3XXDzJ/ndunBxFcH0nTQ== X-Google-Smtp-Source: ABdhPJy4E0vJOJpFn2dtFuJvIo31XqxsO2A2l/zIgkxN2EgX2oY+90UDMspe6mET/djpD5FLURGDgJHVOkdXu1D6ku4= X-Received: by 2002:a05:6902:124f:: with SMTP id t15mr8144006ybu.161.1633106059244; Fri, 01 Oct 2021 09:34:19 -0700 (PDT) MIME-Version: 1.0 References: <20210902231813.3597709-1-surenb@google.com> <20210902231813.3597709-2-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Fri, 1 Oct 2021 09:34:08 -0700 Message-ID: Subject: Re: [PATCH v9 2/3] mm: add a field to store names for private anonymous memory To: Rasmus Villemoes 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, 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: 5C6362343 X-Stat-Signature: xhr1bffw75c6wt9xioqqqghwx91od7k1 Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=pWMrJuJh; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf22.hostedemail.com: domain of surenb@google.com designates 209.85.219.178 as permitted sender) smtp.mailfrom=surenb@google.com X-HE-Tag: 1633106060-38396 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 Fri, Oct 1, 2021 at 12:01 AM Rasmus Villemoes wrote: > > On 03/09/2021 01.18, Suren Baghdasaryan wrote: > > From: Colin Cross > > > > > > changes in v9 > > - Changed max anon vma name length from 64 to 256 (as in the original patch) > > because I found one case of the name length being 139 bytes. If anyone is > > curious, here it is: > > dalvik-/data/dalvik-cache/arm64/apex@com.android.permission@priv-app@GooglePermissionController@GooglePermissionController.apk@classes.art > > I'm not sure that's a very convincing argument. We don't add code > arbitrarily just because some userspace code running on some custom > kernel (ab)uses something in that kernel. Surely that user can come up > with a name that doesn't contain GooglePermissionController twice. > > The argument for using strings and not just a 128 bit uuid was that it > should (also) be human readable, and 250-byte strings are not that. > Also, there's no natural law forcing this to be some power-of-two, and > in fact the implementation means that it's actually somewhat harmful > (give it a 256 char name, and we'll do a 260 byte alloc, which becomes a > 512 byte alloc). So just make the limit 80, the kernel's definition of a > sane line length. Sounds reasonable. I'll set the limit to 80 and will look into the userspace part if we can trim the names to abide by this limit. > As for the allowed chars, it can be relaxed later if convincing arguments can be made. For the disallowed chars, I would like to go with "\\`$[]" set because of the example I presented in my last reply. Since we disallow $, the parsers should be able to process parentheses with no issues I think. > > > > +/* mmap_lock should be read-locked */ > > +static inline bool is_same_vma_anon_name(struct vm_area_struct *vma, > > + const char *name) > > +{ > > + const char *vma_name = vma_anon_name(vma); > > + > > + if (likely(!vma_name)) > > + return name == NULL; > > + > > + return name && !strcmp(name, vma_name); > > It's probably preferable to spell this > > /* either both NULL, or pointers to same refcounted string */ > if (vma_name == name) > return true; > > return name && vma_name && !strcmp(name, vma_name); > > so you have one less conditional in the common case. Ack. > > Rasmus Thanks for the review! Suren.