Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1342686pxa; Sun, 2 Aug 2020 04:26:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuEYzkYruhIaoAyLHHc66iLTBIK1PGJR43puEs5UWtNTA2WNWuVexp9lGPjYktkLWFi9YY X-Received: by 2002:a17:906:b0d5:: with SMTP id bk21mr11900930ejb.93.1596367610689; Sun, 02 Aug 2020 04:26:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596367610; cv=none; d=google.com; s=arc-20160816; b=DBDThw8tcvebC1Aw4Lypd7gMbEhbHv0G8iEF3LiyhulApnmH4Ijww7RHwqvD8eQJNK 1CmigN07TNay2YMZaaO8nGX8yieIstGaF3vXEZF0aC3nj0ydLJa/VTSQ4HOS/vwaV0Jo wblEuwdqz1z0wz0L4cvhXyhuZdZrJhglYUVKjv9oxiJ4DJzgYjdZS6kO12P4K2LcfnEG u1qo/0kNth37h+S23flc64jYfxwemYhRpNpT1lzskuquZDMLQunHgHHkipFL128y9NIx +extOcv+3pl0Ni1jB9RGWKTu0UsDm53yfjGoENIkpKxH7Jc5U5RDoJrYUMFfxa/2fdhe BlPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=Yz//Z4FgbJ1KhwOlD52Mt7GFxHyjsRWk7vcz/XO09Eg=; b=AYZ53tChvTciYZVTzHOquLwNtAzUsgth6poe+hIQ8/K1IVN+Zz+lozUY3C8+tsvi4N IqIxXCqb61gErakcBIsQ6Bsr054A/7HrcgwmoixCMaNQecsFkAcRrRqlJym++i2O0pp0 dFfpXilzxz2W/Z4dD3p8nkRKlDjPYDQRO6rNQn4PMwmZz3NB/nBXN7LAcKcKGhYJhZzt s0TFN2qjFFXQ5Lwzo/xi4b1qZzI3Y4TPmLhFbLOA+zrjEEyKqKIiUDyLrAV/UV4FI2q4 lH8l/IU7zQKRPxy5t5jzs0vMytt2+VvRgmEY5eQH8BNjLvZFJUcKb2LydTWaD1PvNqkO rayQ== ARC-Authentication-Results: i=1; mx.google.com; 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 q8si7396477edn.409.2020.08.02.04.26.26; Sun, 02 Aug 2020 04:26:50 -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; 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 S1728014AbgHBLZc (ORCPT + 99 others); Sun, 2 Aug 2020 07:25:32 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:58157 "EHLO relay7-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726578AbgHBLZb (ORCPT ); Sun, 2 Aug 2020 07:25:31 -0400 X-Originating-IP: 180.110.142.179 Received: from localhost (unknown [180.110.142.179]) (Authenticated sender: fly@kernel.page) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 64DFD20007; Sun, 2 Aug 2020 11:24:54 +0000 (UTC) Date: Sun, 2 Aug 2020 19:23:47 +0800 From: Pengfei Li To: Daniel Jordan Cc: Hugh Dickins , akpm@linux-foundation.org, bmt@zurich.ibm.com, dledford@redhat.com, willy@infradead.org, vbabka@suse.cz, kirill.shutemov@linux.intel.com, jgg@ziepe.ca, alex.williamson@redhat.com, cohuck@redhat.com, dbueso@suse.de, jglisse@redhat.com, jhubbard@nvidia.com, ldufour@linux.ibm.com, Liam.Howlett@oracle.com, peterz@infradead.org, cl@linux.com, jack@suse.cz, rientjes@google.com, walken@google.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, fly@kernel.page Subject: Re: [PATCH 2/2] mm, util: account_locked_vm() does not hold mmap_lock Message-ID: <20200802192347.534ece64.fly@kernel.page> In-Reply-To: <20200730205705.ityqlyeswzo5dkow@ca-dmjordan1.us.oracle.com> References: <20200726080224.205470-1-fly@kernel.page> <20200726080224.205470-2-fly@kernel.page> <20200730205705.ityqlyeswzo5dkow@ca-dmjordan1.us.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 30 Jul 2020 16:57:05 -0400 Daniel Jordan wrote: > On Wed, Jul 29, 2020 at 12:21:11PM -0700, Hugh Dickins wrote: > > On Sun, 26 Jul 2020, Pengfei Li wrote: > > > > > Since mm->locked_vm is already an atomic counter, > > > account_locked_vm() does not need to hold mmap_lock. > > > > I am worried that this patch, already added to mmotm, along with its > > 1/2 making locked_vm an atomic64, might be rushed into v5.9 with > > just that two-line commit description, and no discussion at all. > > > > locked_vm belongs fundamentally to mm/mlock.c, and the lock to guard > > it is mmap_lock; and mlock() has some complicated stuff to do under > > that lock while it decides how to adjust locked_vm. > > > > It is very easy to convert an unsigned long to an atomic64_t, but > > "atomic read, check limit and do stuff, atomic add" does not give > > the same guarantee as holding the right lock around it all. > > Yes, this is why I withdrew my attempt to do something similar last > year, I didn't want to make the accounting racy. Stack and heap > growing and mremap would be affected in addition to mlock. > > It'd help to hear more about the motivation for this. > Thanks for your comments. My motivation is to allow mm related counters to be safely read and written without holding mmap_lock. But sorry i didn't do well. -- Pengfei