From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757748AbcBCW4N (ORCPT ); Wed, 3 Feb 2016 17:56:13 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:47311 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757097AbcBCW4I (ORCPT ); Wed, 3 Feb 2016 17:56:08 -0500 Date: Wed, 3 Feb 2016 14:56:07 -0800 From: Andrew Morton To: "Kirill A. Shutemov" Cc: Andrea Arcangeli , Hugh Dickins , Dave Hansen , Mel Gorman , Rik van Riel , Vlastimil Babka , Christoph Lameter , Naoya Horiguchi , Steve Capper , "Aneesh Kumar K.V" , Johannes Weiner , Michal Hocko , Jerome Marchand , Sasha Levin , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 1/4] rmap: introduce rmap_walk_locked() Message-Id: <20160203145607.ec7fe6f46208a5da1a8f795a@linux-foundation.org> In-Reply-To: <20160203224507.GA22605@black.fi.intel.com> References: <1454512459-94334-1-git-send-email-kirill.shutemov@linux.intel.com> <1454512459-94334-2-git-send-email-kirill.shutemov@linux.intel.com> <20160203144019.9b58b1ba496371a11cc86568@linux-foundation.org> <20160203224507.GA22605@black.fi.intel.com> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 4 Feb 2016 01:45:07 +0300 "Kirill A. Shutemov" wrote: > On Wed, Feb 03, 2016 at 02:40:19PM -0800, Andrew Morton wrote: > > On Wed, 3 Feb 2016 18:14:16 +0300 "Kirill A. Shutemov" wrote: > > > > > rmap_walk_locked() is the same as rmap_walk(), but caller takes care > > > about relevant rmap lock. It only supports anonymous pages for now. > > > > > > It's preparation to switch THP splitting from custom rmap walk in > > > freeze_page()/unfreeze_page() to generic one. > > > > > > ... > > > > > > +/* Like rmap_walk, but caller holds relevant rmap lock */ > > > +int rmap_walk_locked(struct page *page, struct rmap_walk_control *rwc) > > > +{ > > > + /* only for anon pages for now */ > > > + VM_BUG_ON_PAGE(!PageAnon(page) || PageKsm(page), page); > > > + return rmap_walk_anon(page, rwc, true); > > > +} > > > > Should be rmap_walk_anon_locked()? > > I leave interface open for further extension for file mappings, once it > will be needed. Interface is mirroring plain rmap_walk() hm, yes, I see. > If you prefer to rename the function, I can do it too. Well, what does "unlocked" mean in the context of rmap_walk_ksm() and rmap_walk_file()? That the caller holds totally different locks. I expect that sitting down and writing out the interface definition for such an rmap_walk_locked() would reveal that we shouldn't have created it. I mean, if the caller is to call such an rmap_walk_locked(), he first needs to work out if it's a ksm page or an anon page or a file page, then take the appropriate lock and then call rmap_walk_locked(). That's silly - at this point he should directly call rmap_walk_ksm_locked()?