Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1595497pxb; Thu, 7 Oct 2021 10:53:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvsAcUx2x7GroHIt9vYXZwEB+oaVFtyBo0uwJxlOVSj6zcEkYLbEXbUaUZ522r/IYriQJe X-Received: by 2002:a17:902:c94f:b0:13f:4b5:cddd with SMTP id i15-20020a170902c94f00b0013f04b5cdddmr5018234pla.58.1633629183490; Thu, 07 Oct 2021 10:53:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633629183; cv=none; d=google.com; s=arc-20160816; b=iCEvFC8cbRFFKK/pRxXdkG+XdAMD2/0TZIYmd/eMAjvAIgCuA+CKrqDDa/kXthuL7z x6Y5AAhbByo8jnhjDF5bZ6zWtoDXtVISQFfUDonMrlTANNNSCcK8Y9vrF4ADIyS/vaRH Mf1jpsYZMYhoOLtJMuQdVTiVCxwYTk8HpfRfPXeNNrvnWZZ96AJibqq80IQNEbxD9RLX eL7Ts0tP6/Fp/5oXCRWprT1kM2QxrTW1CWCx0HmLW6FU1swug8FhRgHGkL4NZlxr9pIf lIUFvO2BV1mb0ofb0HvF+No6lUSctX18nfdCcE+YKLgcRVQ79G9OOXqyVMvEqM9A4kJ9 sKMA== 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=NZcdFdLklF2D8wG5a28IWE28EnK8YrlZxMIkR94gcXg=; b=aRxUoSu1htwlVYGUFN22sPNDeSEV8ft5fZ5SP1yfMpycs8bULSI+grrKTSzLEIAB40 6/M4dS7gjMc85SGoHrhmaap222iXCAadKwfEdZt4dC+rh6nhM/91KLiKYxpEF9deJbND 7b9Q/bIdViy5GvIlYtLVMSh3CMAXz1+0vRiTt5vADcKymXYr5GogrlXIpzwqhe7mVmjY m38DmQUw3IARvl9JtkCqEC+2y+cTChG0Fe5/DoemgEhYmT2it5gN9/Pej3TMrzzW3rcV bPxe5s/icNb/NGj8D6tbmKj2TgAQnF/YDmk+E7k4oJgguKnAKEfg4yxYgbgd42waADz7 /jNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ii4rM8Lz; 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 q91si63211pja.33.2021.10.07.10.52.50; Thu, 07 Oct 2021 10:53:03 -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=ii4rM8Lz; 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 S243172AbhJGRwc (ORCPT + 99 others); Thu, 7 Oct 2021 13:52:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242948AbhJGRwb (ORCPT ); Thu, 7 Oct 2021 13:52:31 -0400 Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90C13C061760 for ; Thu, 7 Oct 2021 10:50:37 -0700 (PDT) Received: by mail-yb1-xb2f.google.com with SMTP id v195so15343796ybb.0 for ; Thu, 07 Oct 2021 10:50:37 -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=NZcdFdLklF2D8wG5a28IWE28EnK8YrlZxMIkR94gcXg=; b=ii4rM8LzrLeipvkrLI6sF2XMP2pYN1zP2MMXV9cnIwjuzdbJHr0PQpeFOd3KTC+40n daj4ueJa2JF/8jd+7KE8ZpdESfFGK5l4m+2s8U8LxGYrHX3x2VnHVb6hcN50EYm5gTpM b15jPV6rJ1CCYg/qLLGgQltU7yUdmfasW7NkOnV9MZdefsJJgTwXpLQwCUZ0cvTxYu4b FM0XFSlN0hRSDl5ECN2ziCzhqY8CIM7jdFMI6hhJQTQQlt6bdbIr+oONLgaiJRJ2+bwz bV6byWHhxCzFT5G1xzBWvTFIQOn3OnOsIl8tjkX58LjAx81lAkDOzCb/AbEjkB4ITKcI LjIg== 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=NZcdFdLklF2D8wG5a28IWE28EnK8YrlZxMIkR94gcXg=; b=BeZsLFHvmYIxp8I0P/0D48Mq43G/vEa5ZtPkravndwzjwJLc5OBCxj7kGiSV3I6uF5 DegohNb010iqV+8H20wY5TCGcQT+osg3HQdz+hHiGIez6uSs2OtYM5BYVRJQW7qj4J+1 YWmP6AS9UWd9yeRsRP7vz4MY6ldBzlERNUrFBvJss2Yj846qJOK/iVXTJEyWMaO8RJb4 jX3KaqBjWoTKec8MskGVpJHEyGwPeIZC4K7L6qFDBfqRjEh3N9UmpniSzPDKALEYPym2 khW8CLSVSSpAZWJWjso3gTMNLHEV0TsUT5AgcdnSSId6aM3EaiAYJO6ucn6WBDQ07YWw sgbA== X-Gm-Message-State: AOAM532qViyP9C9Cx+P+cQ2JyZXPfXSm0xTQimHbFV0O8LQqLzzzCNLd BaKzRf9wAhgGiGGtT3IfmyfCmt7yyF0YmtuYfJ1ZnQ== X-Received: by 2002:a25:8411:: with SMTP id u17mr6232017ybk.376.1633629035946; Thu, 07 Oct 2021 10:50:35 -0700 (PDT) MIME-Version: 1.0 References: <6b15c682-72eb-724d-bc43-36ae6b79b91a@redhat.com> <20211006175821.GA1941@duo.ucw.cz> <92cbfe3b-f3d1-a8e1-7eb9-bab735e782f6@rasmusvillemoes.dk> <20211007101527.GA26288@duo.ucw.cz> In-Reply-To: From: Suren Baghdasaryan Date: Thu, 7 Oct 2021 10:50:24 -0700 Message-ID: Subject: Re: [PATCH v10 3/3] mm: add anonymous vma name refcounting To: Michal Hocko Cc: Pavel Machek , Rasmus Villemoes , David Hildenbrand , John Hubbard , Andrew Morton , Colin Cross , Sumit Semwal , 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 , 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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 7, 2021 at 10:31 AM Michal Hocko wrote: > > On Thu 07-10-21 09:58:02, Suren Baghdasaryan wrote: > > On Thu, Oct 7, 2021 at 9:40 AM Michal Hocko wrote: > > > > > > On Thu 07-10-21 09:04:09, Suren Baghdasaryan wrote: > > > > On Thu, Oct 7, 2021 at 3:15 AM Pavel Machek wrote: > > > > > > > > > > Hi! > > > > > > > > > > > >> Hmm, so the suggestion is to have some directory which contains files > > > > > > >> representing IDs, each containing the string name of the associated > > > > > > >> vma? Then let's say we are creating a new VMA and want to name it. We > > > > > > >> would have to scan that directory, check all files and see if any of > > > > > > >> them contain the name we want to reuse the same ID. > > > > > > > > > > > > > > I believe Pavel meant something as simple as > > > > > > > $ YOUR_FILE=$YOUR_IDS_DIR/my_string_name > > > > > > > $ touch $YOUR_FILE > > > > > > > $ stat -c %i $YOUR_FILE > > > > > > > > Ah, ok, now I understand the proposal. Thanks for the clarification! > > > > So, this would use filesystem as a directory for inode->name mappings. > > > > One rough edge for me is that the consumer would still need to parse > > > > /proc/$pid/maps and convert [anon:inode] into [anon:name] instead of > > > > just dumping the content for the user. Would it be acceptable if we > > > > require the ID provided by prctl() to always be a valid inode and > > > > show_map_vma() would do the inode-to-filename conversion when > > > > generating maps/smaps files? I know that inode->dentry is not > > > > one-to-one mapping but we can simply output the first dentry name. > > > > WDYT? > > > > > > No. You do not want to dictate any particular way of the mapping. The > > > above is just one way to do that without developing any actual mapping > > > yourself. You just use a filesystem for that. Kernel doesn't and > > > shouldn't understand the meaning of those numbers. It has no business in > > > that. > > > > > > In a way this would be pushing policy into the kernel. > > > > I can see your point. Any other ideas on how to prevent tools from > > doing this id-to-name conversion themselves? > > I really fail to understand why you really want to prevent them from that. > Really, the whole thing is just a cookie that kernel maintains for memory > mappings so that two parties can understand what the meaning of that > mapping is from a higher level. They both have to agree on the naming > but the kernel shouldn't dictate any specific convention because the > kernel _doesn't_ _care_. These things are not really anything actionable > for the kernel. It is just a metadata. The desire is for one of these two parties to be a human who can get the data and use it as is without additional conversions. /proc/$pid/maps could report FD numbers instead of pathnames, which could be converted to pathnames in userspace. However we do not do that because pathnames are more convenient for humans to identify a specific resource. Same logic applies here IMHO. > > -- > Michal Hocko > SUSE Labs