Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1225703ybi; Fri, 31 May 2019 16:17:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqwPbarX7MGFCXWHl8ezOH3/k1+vtYDhsb32FT3hzchfl0JaNvJrmiNAYlxOKON77JJseenH X-Received: by 2002:a17:902:8303:: with SMTP id bd3mr12589490plb.240.1559344643726; Fri, 31 May 2019 16:17:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559344643; cv=none; d=google.com; s=arc-20160816; b=qx6mLygjFRkn3drU8IrJ7KVZvPu+t5dPuLlkBtgJw1wVX54Vf2Na3vHmfkUezXipTx hD0CVTe5nnx+Jym/gBgz9mc6adrAmxVSvUtPTd4mcjEq9XsIXH5suKd6ZfQnXNVXETlR /Tr93xeiGy+TZ+1Nr5x4caKAz3VkfyosdnHa9pGOc2IYX7IQpiWlHNiNIL+Kcw+TjsWn keRvBngsUQhKciGL7CHAQhn4Y7cjY60NX5A/e4XXEld9xZso0ZrGSwX0QaipmjC2EIT0 UnzGNph5MwOHj6Rpr7eGi60ryDKOQwhXjuwu5lL5QhZk4zOP0+4JUy1y6lwbVMrZtLSO nGaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=sqg+k083UjuBaC9GIrtmvRgUBVLo9R/vwLVNgUStm7o=; b=lYTiwumXhYpT9DKgxPKhHMMPGoj6fak3TBKLRZvtjqVyohCv7EHLuXl5ArbzDOT14N Kxqf3nHQ0ae9lsadn9NTpgdvyv0IrIqkLrw6kum92l/G0wG9xDjmcGKlkVhOlIf7PisV dQUDbVTvU+SNLPM/IGHitt3wYyj+c0E9zV4a9uMndTTuXu4nOPzcwgE8i7Cj1mCD5duv B3uiD+tElRvUrDjifO2GWdVISOYjXHFxQC8RfTBjvx7Pxg/vyfEZiu+fk6sOgccgQ+d0 EKc5vjDKBuyxCRZ5VBlyaSHhScJxa+lkuurjLKMpUU1FHLFhhAMmPOW5eulcxpLCh12w pntw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=TIt5gc6s; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q82si9141795pfc.12.2019.05.31.16.17.07; Fri, 31 May 2019 16:17:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=TIt5gc6s; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726738AbfEaXOt (ORCPT + 99 others); Fri, 31 May 2019 19:14:49 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:43211 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726589AbfEaXOs (ORCPT ); Fri, 31 May 2019 19:14:48 -0400 Received: by mail-pf1-f196.google.com with SMTP id c6so7057989pfa.10; Fri, 31 May 2019 16:14:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=sqg+k083UjuBaC9GIrtmvRgUBVLo9R/vwLVNgUStm7o=; b=TIt5gc6sWWBRszHh4EYFe1xGzN/GdjxvaWM8K2lb6Xim/4FxDuLYAD1Ln2BwGq45N+ //hSJoE0haJkdEoYT574H8cfE9MQgXFzRw9sOmwzIyx/aypjCsv4NovefY7K4x0WskEI IVectjaxNeGeZFgbtOeR9p5BUkF0lD48nEbVmxysSoLNH++JgwHrLIIZUaAC+hoCL9rz n1qDpabUzsB7ye5w7gl61SKBt5e5S2OL0wW9YBBdj8rdOiA82r+94WHIIEKuKl0Y2sDz QaC76D/Cz/zHvImRoMHQofTytuSRimSdWNmb8t32cHGYtCcoWqLEK3GnHTXJbc6FyvpX Ywog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=sqg+k083UjuBaC9GIrtmvRgUBVLo9R/vwLVNgUStm7o=; b=QeUNKpuZpD8nUnONGI5Ch972FjvUb21DmETWNBV9gixPeLWCmHtVYJYiamRsPkDwj9 3cmhpgnLtDNXStTfyrTGI4Nq7Jpgdcr1Mu7zFYgdpWmo2R5yTVevtFdGqgQP3uZVJ1cv gEYBUdUYskR1RiV014UbksyIWFOUdPynLriUd1oIpS4NKpeFDDUJPl0rwdqKlkb91Ly7 or/wgXAMYSz0Xbga5GuCUVqBGDYirLDqUwzXhAs/wy4gDuSV85C3fJgpv+MIQpM7Kjji DBb4Qk0cRc4+LgzGmOJj6mmIAh7HV5Yk9UlZVLyMridCTuAizBIte7G1ASuGFNLLsFiq NaPQ== X-Gm-Message-State: APjAAAU8TNITciiLNd4yDiH41u+ka0sPU+4IdS2oTmyvDPda7egEuhJV 4wUVjlS076V/uKuc9lixl7A= X-Received: by 2002:a63:c203:: with SMTP id b3mr11763122pgd.398.1559344487353; Fri, 31 May 2019 16:14:47 -0700 (PDT) Received: from google.com ([122.38.223.241]) by smtp.gmail.com with ESMTPSA id j7sm1044314pgp.88.2019.05.31.16.14.40 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 31 May 2019 16:14:46 -0700 (PDT) Date: Sat, 1 Jun 2019 08:14:38 +0900 From: Minchan Kim To: Johannes Weiner Cc: Andrew Morton , linux-mm , LKML , linux-api@vger.kernel.org, Michal Hocko , Tim Murray , Joel Fernandes , Suren Baghdasaryan , Daniel Colascione , Shakeel Butt , Sonny Rao , Brian Geffon , jannh@google.com, oleg@redhat.com, christian@brauner.io, oleksandr@redhat.com, hdanton@sina.com Subject: Re: [RFCv2 3/6] mm: introduce MADV_PAGEOUT Message-ID: <20190531231438.GA248371@google.com> References: <20190531064313.193437-1-minchan@kernel.org> <20190531064313.193437-4-minchan@kernel.org> <20190531165927.GA20067@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190531165927.GA20067@cmpxchg.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hey Johannes, On Fri, May 31, 2019 at 12:59:27PM -0400, Johannes Weiner wrote: > Hi Michan, > > this looks pretty straight-forward to me, only one kink: > > On Fri, May 31, 2019 at 03:43:10PM +0900, Minchan Kim wrote: > > --- a/mm/vmscan.c > > +++ b/mm/vmscan.c > > @@ -2126,6 +2126,83 @@ static void shrink_active_list(unsigned long nr_to_scan, > > nr_deactivate, nr_rotated, sc->priority, file); > > } > > > > +unsigned long reclaim_pages(struct list_head *page_list) > > +{ > > + int nid = -1; > > + unsigned long nr_isolated[2] = {0, }; > > + unsigned long nr_reclaimed = 0; > > + LIST_HEAD(node_page_list); > > + struct reclaim_stat dummy_stat; > > + struct scan_control sc = { > > + .gfp_mask = GFP_KERNEL, > > + .priority = DEF_PRIORITY, > > + .may_writepage = 1, > > + .may_unmap = 1, > > + .may_swap = 1, > > + }; > > + > > + while (!list_empty(page_list)) { > > + struct page *page; > > + > > + page = lru_to_page(page_list); > > + if (nid == -1) { > > + nid = page_to_nid(page); > > + INIT_LIST_HEAD(&node_page_list); > > + nr_isolated[0] = nr_isolated[1] = 0; > > + } > > + > > + if (nid == page_to_nid(page)) { > > + list_move(&page->lru, &node_page_list); > > + nr_isolated[!!page_is_file_cache(page)] += > > + hpage_nr_pages(page); > > + continue; > > + } > > + > > + mod_node_page_state(NODE_DATA(nid), NR_ISOLATED_ANON, > > + nr_isolated[0]); > > + mod_node_page_state(NODE_DATA(nid), NR_ISOLATED_FILE, > > + nr_isolated[1]); > > + nr_reclaimed += shrink_page_list(&node_page_list, > > + NODE_DATA(nid), &sc, TTU_IGNORE_ACCESS, > > + &dummy_stat, true); > > + while (!list_empty(&node_page_list)) { > > + struct page *page = lru_to_page(&node_page_list); > > + > > + list_del(&page->lru); > > + putback_lru_page(page); > > + } > > + mod_node_page_state(NODE_DATA(nid), NR_ISOLATED_ANON, > > + -nr_isolated[0]); > > + mod_node_page_state(NODE_DATA(nid), NR_ISOLATED_FILE, > > + -nr_isolated[1]); > > + nid = -1; > > + } > > + > > + if (!list_empty(&node_page_list)) { > > + mod_node_page_state(NODE_DATA(nid), NR_ISOLATED_ANON, > > + nr_isolated[0]); > > + mod_node_page_state(NODE_DATA(nid), NR_ISOLATED_FILE, > > + nr_isolated[1]); > > + nr_reclaimed += shrink_page_list(&node_page_list, > > + NODE_DATA(nid), &sc, TTU_IGNORE_ACCESS, > > + &dummy_stat, true); > > + mod_node_page_state(NODE_DATA(nid), NR_ISOLATED_ANON, > > + -nr_isolated[0]); > > + mod_node_page_state(NODE_DATA(nid), NR_ISOLATED_FILE, > > + -nr_isolated[1]); > > + > > + while (!list_empty(&node_page_list)) { > > + struct page *page = lru_to_page(&node_page_list); > > + > > + list_del(&page->lru); > > + putback_lru_page(page); > > + } > > + > > + } > > The NR_ISOLATED accounting, nid parsing etc. is really awkward and > makes it hard to see what the function actually does. > > Can you please make those ISOLATED counters part of the isolation API? > Your patch really shows this is an overdue cleanup. Yeah, that was very painful. > > These are fast local percpu counters, we don't need the sprawling > batching we do all over vmscan.c, migrate.c, khugepaged.c, > compaction.c etc. Isolation can increase the counter page by page, and > reclaim or putback can likewise decrease them one by one. > > It looks like mlock is the only user of the isolation api that does > not participate in the NR_ISOLATED_* counters protocol, but I don't > see why it wouldn't, or why doing so would hurt. > > There are also seem to be quite a few callsites that use the atomic > versions of the counter API when they're clearly under the irqsafe > lru_lock. That would be fixed automatically by this work as well. I agree all points so will prepare clean up patch.