Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1240137pxb; Thu, 7 Oct 2021 03:57:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9tSf6KAy37cfmfM/VMayL3yazni4sXvJyyKE+H1yugkymYC9urSXTg/tLIkpky+6UcgZo X-Received: by 2002:a17:906:2c09:: with SMTP id e9mr4887506ejh.410.1633604225222; Thu, 07 Oct 2021 03:57:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633604225; cv=none; d=google.com; s=arc-20160816; b=d8//7GMOGAqClQVoIowUnLaJBbCHAq3kQnwi/wVc0s+A91vz1ez3BHkLiNrUJb4PzE c+8jo/wJ5Id/PZ8O2BEiNfygeNRaQpN5CcBuFDqdzkaCUDKZdvcOiVr3QUe4J5rKyr2M 291xYJ1W7zyEUQtFGSbtZrCpbvPsztYKzlIX9CiKqaphmElpuMZeR0kwxgu13NKuVxoh cxGKjzXIK+E2W9IDizSp635K1kxL7eY+MpzntFMfV5hZ94oCCn1i29XXaMLZbkcFcpKd 7pYZUxof/9yCW9KzLGmMJ8cwL668Ev5ZxDGKaabpqUQA5YostxPQeGISHwiww/ZMzN6a 9CJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=adlW7pivg4cyteV3mlsXKz5Do/ag2vJ2th3mLW+Jmhk=; b=03qkF4FI2pcBdcQtpfjOFmbYbdlSPbsGSzdMSztYzkDTQ8mXbis/0dBMB48bN+s2RM LWhXo68P2MrQJUvOSAx+Sx+rE3I8KiNvWQVDTQ7lX4xEm8OL8AQsgjwDGCR2xicmUZQs 1aztfVJBjIVEc1Ogeyhj9vOY4Dt5Aj5R/+wiBtEUuqkMo+QMFaUe6VikWsaqjsPR+vuK V3zfV9djn5SoN4yWGAEnjml8E9dt/GZejEm1E4FZAXDD339HDvnN6akroPtAPZmnGkV3 3GRfsKxiWtXltz+JmCSZA2dJlgklEA0jJDOPRDxutnwnOPr5tjzlOOIlSWejuYwkZa+3 6rvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=NWv2fnZX; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y11si19081626edq.411.2021.10.07.03.56.41; Thu, 07 Oct 2021 03:57:05 -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=@rasmusvillemoes.dk header.s=google header.b=NWv2fnZX; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240208AbhJGIth (ORCPT + 99 others); Thu, 7 Oct 2021 04:49:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232348AbhJGItd (ORCPT ); Thu, 7 Oct 2021 04:49:33 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EED00C061746 for ; Thu, 7 Oct 2021 01:47:39 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id n8so21062433lfk.6 for ; Thu, 07 Oct 2021 01:47:39 -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=adlW7pivg4cyteV3mlsXKz5Do/ag2vJ2th3mLW+Jmhk=; b=NWv2fnZXyOmBKQNz9D7DBaxjTucq2XfkEMTsgzUE8HR+WVOhbVAUU4xS7nXJRwqJF8 g3q1WrbffIpNZTnYHCkKMDKRrc3rJ2PvfatVUE2Uw1i6BVBTwiccMxMJj/YAMu2MuKJ7 9XEcOXAoCIocfpPBryXu5bKAKs+AlDSqnYUtA= 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=adlW7pivg4cyteV3mlsXKz5Do/ag2vJ2th3mLW+Jmhk=; b=y1tB0LZy1UZ5/NFE0FSCiDGyMQ1hDGvqLSb25tN5UQD43Qr5CLwTn78M3l2GKt1lGX K+8U2PC1EYdEztCPrIkJfuE8cG8vkxosFwVU1PSaXbZumEYRKMEZ82kxVLnuR0En/csf /RPXzpmlj7iGr3LDbjxgzEX+U+pU09SANb2uvyw9TWQhIcquE62rLc4AySSFdzjPH9DA vWClQDIgRkAid2+bJ8DivywT3Z1tI0kirSTQxrvPmsqIt268JynjvJGhL6v4cq46HkFO zuCxN0Y6j87HWiR2fzI2vTTT8BveC5UxIYooEiAo9ZncL15FrBI2DCsEIg3ITgcxyDV6 yvHA== X-Gm-Message-State: AOAM532PiigV+Z4zb5S12zwFqJxOjzCDiRAsRs3hjkgMIhrbI+YX59qK 2cu80iKkRl3PiLzFgxDZrb2UUA== X-Received: by 2002:a05:6512:228f:: with SMTP id f15mr2982523lfu.253.1633596454456; Thu, 07 Oct 2021 01:47:34 -0700 (PDT) Received: from [172.16.11.1] ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id l23sm2716647ljg.99.2021.10.07.01.47.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 07 Oct 2021 01:47:34 -0700 (PDT) Subject: Re: [PATCH v10 3/3] mm: add anonymous vma name refcounting To: Michal Hocko , Suren Baghdasaryan Cc: Pavel Machek , 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 References: <20211005184211.GA19804@duo.ucw.cz> <20211005200411.GB19804@duo.ucw.cz> <6b15c682-72eb-724d-bc43-36ae6b79b91a@redhat.com> <20211006175821.GA1941@duo.ucw.cz> From: Rasmus Villemoes Message-ID: <92cbfe3b-f3d1-a8e1-7eb9-bab735e782f6@rasmusvillemoes.dk> Date: Thu, 7 Oct 2021 10:47:31 +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: Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/10/2021 10.10, Michal Hocko wrote: > On Wed 06-10-21 11:18:31, Suren Baghdasaryan wrote: >> On Wed, Oct 6, 2021 at 10:58 AM Pavel Machek wrote: > [...] >>> That "central facility" option can be as simple as "mkdir >>> /somewhere/sanitized_id", using inode numbers for example. You don't >>> really need IPC. >> >> 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 So in terms of syscall overhead, that would be open(..., O_CREAT | O_CLOEXEC), fstat(), close() - or one could optimistically start by doing a single lstat() if it is normal that the name is already created (which I assume). As for the consumer, one can't directly map an inode number to a dentry, but whoever first creates the name->id mapping could also be responsible for doing a "sprintf(buf, "/id/to/name/%016lx", id); symlink(name, buf)". And if one did the optimistic lstat() succesfully, one would know that someone else created the file and thus the symlink. And since the operations are idempotent, the obvious races are irrelevant. Then the consumer would only need to do a readlink() to get the name. But that would only be for presentation to a human. Internally all the aggregation based on the type of anon mem the tool might as well do in terms of the integer id. > YOUR_IDS_DIR can live on a tmpfs and you can even implement a policy on > top of that (who can generate new ids, gurantee uniqness etc...). > > The above is certainly not for free of course but if you really need a > system wide consistency when using names then you need some sort of > central authority. How you implement that is not all that important > but I do not think we want to handle that in the kernel. IDK. If the whole thing could be put behind a CONFIG_ knob, with _zero_ overhead when not enabled (and I'm a bit worried about all the functions that grow an extra argument that gets passed around), I don't mind the string interface. But I don't really have a say either way. Rasmus