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 4D832C433EF for ; Fri, 1 Oct 2021 07:01:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AB72B61166 for ; Fri, 1 Oct 2021 07:01:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AB72B61166 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=rasmusvillemoes.dk Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 269AB9400F4; Fri, 1 Oct 2021 03:01:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1F2809400E4; Fri, 1 Oct 2021 03:01:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 093259400F4; Fri, 1 Oct 2021 03:01:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0168.hostedemail.com [216.40.44.168]) by kanga.kvack.org (Postfix) with ESMTP id E95C69400E4 for ; Fri, 1 Oct 2021 03:01:28 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id A3D692B37C for ; Fri, 1 Oct 2021 07:01:28 +0000 (UTC) X-FDA: 78646972656.17.D2A82CD Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by imf27.hostedemail.com (Postfix) with ESMTP id 31EAF700196A for ; Fri, 1 Oct 2021 07:01:28 +0000 (UTC) Received: by mail-lf1-f44.google.com with SMTP id e15so35095075lfr.10 for ; Fri, 01 Oct 2021 00:01:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=GAfZt0MoHwEJLBdGh3slmVs3mLy3iUfAjh3mV36d5Ls=; b=ROdphRH6lMiRvMmn1nm8oaMaiETamysG3Q0ngWjuTaJIRPQKI5fSRbTZ4rw0TUP847 Pi0wslg6s/LWyZkzrxDcolOlhxrdfgGttEI+JQwcPX/qFBQBXriLXNO40SiKLvdfFgdo Kvfkwr7+GAZthgQ8GYGf+5TMgmfbyOmHcvkfE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=GAfZt0MoHwEJLBdGh3slmVs3mLy3iUfAjh3mV36d5Ls=; b=LP9vZNRQ68uYv0gizSG6sinLGQeq9JxV1vcWiymIZyHIlIFDeeYvpmks/4XnZch1E8 u4Wmb77AlD795cgy3kySpNmiKUK/jEaqjJozcHRNMJ4yFpILpNW1VmHxc/yqLVG9US66 wB6Sl7AmrbLdkhCRpq8FPD3y7X4czha5ECCcsv+uWHa5rq/A3U7v9SHLhODsC2rhTKZq lm4NZGAhfoBZK34kyZ7h2an3dmV6JFe0IFGyp6vdzvu3+tvSQjhyAmvM0IZ4i9FIc7QF yGzFtXA9Acfqbcjc38a7PQyUZmABplRvcgxYsFA+xkW51x7g2D7Tu88/qCkrTUAF5YM6 VgBA== X-Gm-Message-State: AOAM532eEMAapeVMmB4q4HYfAnbG6ZaKmRipCY1bkmzOxN4ocAYxjdGb HH+Ue+btAHokNiS8L/gfTsZTfA== X-Google-Smtp-Source: ABdhPJyXXUEJmAjiOjBr8lgw5nWSpdbiu6T6G5ePA3Lbwqd6VdlF8fBVEdmGWS9e5qpsKpJFjDh9yQ== X-Received: by 2002:a2e:1557:: with SMTP id 23mr10790432ljv.84.1633071686513; Fri, 01 Oct 2021 00:01:26 -0700 (PDT) Received: from [172.16.11.1] ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id q22sm447517lfp.174.2021.10.01.00.01.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 01 Oct 2021 00:01:25 -0700 (PDT) Subject: Re: [PATCH v9 2/3] mm: add a field to store names for private anonymous memory To: Suren Baghdasaryan , akpm@linux-foundation.org Cc: ccross@google.com, sumit.semwal@linaro.org, mhocko@suse.com, dave.hansen@intel.com, keescook@chromium.org, willy@infradead.org, kirill.shutemov@linux.intel.com, vbabka@suse.cz, hannes@cmpxchg.org, corbet@lwn.net, viro@zeniv.linux.org.uk, rdunlap@infradead.org, kaleshsingh@google.com, peterx@redhat.com, rppt@kernel.org, peterz@infradead.org, catalin.marinas@arm.com, vincenzo.frascino@arm.com, chinwen.chang@mediatek.com, axelrasmussen@google.com, aarcange@redhat.com, jannh@google.com, apopple@nvidia.com, jhubbard@nvidia.com, yuzhao@google.com, will@kernel.org, fenghua.yu@intel.com, thunder.leizhen@huawei.com, hughd@google.com, feng.tang@intel.com, jgg@ziepe.ca, guro@fb.com, tglx@linutronix.de, krisman@collabora.com, chris.hyser@oracle.com, pcc@google.com, ebiederm@xmission.com, axboe@kernel.dk, legion@kernel.org, eb@emlix.com, gorcunov@gmail.com, songmuchun@bytedance.com, viresh.kumar@linaro.org, thomascedeno@google.com, sashal@kernel.org, cxfcosmos@gmail.com, linux@rasmusvillemoes.dk, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, kernel-team@android.com References: <20210902231813.3597709-1-surenb@google.com> <20210902231813.3597709-2-surenb@google.com> From: Rasmus Villemoes Message-ID: Date: Fri, 1 Oct 2021 09:01:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210902231813.3597709-2-surenb@google.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 31EAF700196A X-Stat-Signature: 6e7u77qa7737chnayb3nrfb8n6ui6ehn Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=rasmusvillemoes.dk header.s=google header.b=ROdphRH6; dmarc=none; spf=pass (imf27.hostedemail.com: domain of linux@rasmusvillemoes.dk designates 209.85.167.44 as permitted sender) smtp.mailfrom=linux@rasmusvillemoes.dk X-HE-Tag: 1633071688-179206 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 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. As for the allowed chars, it can be relaxed later if convincing arguments can be made. > +/* 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. Rasmus