From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: * X-Spam-Status: No, score=1.2 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FSL_HELO_FAKE,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, T_DKIMWL_WL_HIGH,USER_AGENT_MUTT autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5028DC04AB6 for ; Fri, 31 May 2019 23:14:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 24DC526FE8 for ; Fri, 31 May 2019 23:14:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559344490; bh=x1HO1p2bExzsAsgaaKZAG0juiP+oXQJWy5Vw7XR8R8c=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=C4+vKNbm5MYjvu9gio8lo+agS2nMKEEEwVQvxAPaH9vkolqAEUsU9zgWN9EoTxRSt 2yFpB7CHC1055aEKxxAGY9LOk6EEduEHJezWkkvb+1mhnKKfS7OepoyTfgJaOvelPr nbjDFl/7NoiDKHsiLNq3QaAHuCzvs5o0wwsu+loI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726748AbfEaXOt (ORCPT ); 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-Google-Smtp-Source: APXvYqxX11lcuUNZhgtux5VQO7zQRp/yiNhP/Uuovf9qi9asywvg1BHUnB4cqyA87l6NJmsdUFW+ew== 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.