From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on archive.lwn.net X-Spam-Level: X-Spam-Status: No, score=-5.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by archive.lwn.net (Postfix) with ESMTP id 048EB7D90F for ; Tue, 6 Aug 2019 10:46:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732651AbfHFKqB (ORCPT ); Tue, 6 Aug 2019 06:46:01 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:36747 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730868AbfHFKp5 (ORCPT ); Tue, 6 Aug 2019 06:45:57 -0400 Received: by mail-pg1-f195.google.com with SMTP id l21so41380937pgm.3 for ; Tue, 06 Aug 2019 03:45:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ABKgADdiGa23iy+5xy09f6OBQqR3I/07f0qdbQrp2Ug=; b=BK0x5edz5Iheer/fK6xR02+EYpWEe73+fBNaVu3psDyEfFgQR4iTDEjMX3llLyVbBQ oo5c2wtKKMdHq+s0dbGvvCrA28tZJ7WgRbNvmF9B9TCPhzQEMI365I16VRvzSe8CiyqZ ulIdft17U/LPUUnWy2+R0724GxrzxbZjJPUj8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ABKgADdiGa23iy+5xy09f6OBQqR3I/07f0qdbQrp2Ug=; b=mNNJlvl2AJbs8WUkFPb/Ca4VB/hT/bWEfa+7d6UVfnbSuos81IuCmx9dod/8PWnznY 6LnbUxpHOSAxxZB1jGZujTid2ue8BzejZ1r5XTZAvP5sZ/94WjO5OJe12RedfAXlu3V1 nVGKcvt5nYPwr+SVDNqvWGIF1lFD+Kh0tRHBHS4HnvdJqalTe5oTAVZfzMsWl3dO/ZGm srUArCuRKeT1STWczNec+HwYV8T/+5yTGQ+jq1sCL9jeszlmqnwv7rDv5KsM821PrXrr T2hUPma9CyhXhjq8JIipqww8ApZPCNLHB1RRpZ3dkdsKCbMItKwR2/+PzG5RiS99eusN dJ3w== X-Gm-Message-State: APjAAAVqsmKdDwPNUS5aMwA/ubRkH9tsC+QpHNoEHafF2OGKLV8QDPTy 7qlCMn+VvAEMsvriJLlejujXmA== X-Google-Smtp-Source: APXvYqyKhAOOvSnRzmdX9OiAK7Cu7h4b/c73qpWbsn3JUV5APW6ELiBP2MjwevD8QijB6PWnNqvwJA== X-Received: by 2002:aa7:90d4:: with SMTP id k20mr2919746pfk.78.1565088356112; Tue, 06 Aug 2019 03:45:56 -0700 (PDT) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id b126sm126571952pfa.126.2019.08.06.03.45.54 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 06 Aug 2019 03:45:55 -0700 (PDT) Date: Tue, 6 Aug 2019 06:45:54 -0400 From: Joel Fernandes To: Michal Hocko Cc: linux-kernel@vger.kernel.org, Alexey Dobriyan , Andrew Morton , Borislav Petkov , Brendan Gregg , Catalin Marinas , Christian Hansen , dancol@google.com, fmayer@google.com, "H. Peter Anvin" , Ingo Molnar , Jonathan Corbet , Kees Cook , kernel-team@android.com, linux-api@vger.kernel.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Mike Rapoport , minchan@kernel.org, namhyung@google.com, paulmck@linux.ibm.com, Robin Murphy , Roman Gushchin , Stephen Rothwell , surenb@google.com, Thomas Gleixner , tkjos@google.com, Vladimir Davydov , Vlastimil Babka , Will Deacon Subject: Re: [PATCH v4 4/5] page_idle: Drain all LRU pagevec before idle tracking Message-ID: <20190806104554.GB218260@google.com> References: <20190805170451.26009-1-joel@joelfernandes.org> <20190805170451.26009-4-joel@joelfernandes.org> <20190806084357.GK11812@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190806084357.GK11812@dhcp22.suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-doc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org On Tue, Aug 06, 2019 at 10:43:57AM +0200, Michal Hocko wrote: > On Mon 05-08-19 13:04:50, Joel Fernandes (Google) wrote: > > During idle tracking, we see that sometimes faulted anon pages are in > > pagevec but are not drained to LRU. Idle tracking considers pages only > > on LRU. Drain all CPU's LRU before starting idle tracking. > > Please expand on why does this matter enough to introduce a potentially > expensinve draining which has to schedule a work on each CPU and wait > for them to finish. Sure, I can expand. I am able to find multiple issues involving this. One issue looks like idle tracking is completely broken. It shows up in my testing as if a page that is marked as idle is always "accessed" -- because it was never marked as idle (due to not draining of pagevec). The other issue shows up as a failure in my "swap test", with the following sequence: 1. Allocate some pages 2. Write to them 3. Mark them as idle <--- fails 4. Introduce some memory pressure to induce swapping. 5. Check the swap bit I introduced in this series. <--- fails to set idle bit in swap PTE. Draining the pagevec in advance fixes both of these issues. This operation even if expensive is only done once during the access of the page_idle file. Did you have a better fix in mind? thanks, - Joel > > Signed-off-by: Joel Fernandes (Google) > > --- > > mm/page_idle.c | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/mm/page_idle.c b/mm/page_idle.c > > index a5b00d63216c..2972367a599f 100644 > > --- a/mm/page_idle.c > > +++ b/mm/page_idle.c > > @@ -180,6 +180,8 @@ static ssize_t page_idle_bitmap_read(struct file *file, struct kobject *kobj, > > unsigned long pfn, end_pfn; > > int bit, ret; > > > > + lru_add_drain_all(); > > + > > ret = page_idle_get_frames(pos, count, NULL, &pfn, &end_pfn); > > if (ret == -ENXIO) > > return 0; /* Reads beyond max_pfn do nothing */ > > @@ -211,6 +213,8 @@ static ssize_t page_idle_bitmap_write(struct file *file, struct kobject *kobj, > > unsigned long pfn, end_pfn; > > int bit, ret; > > > > + lru_add_drain_all(); > > + > > ret = page_idle_get_frames(pos, count, NULL, &pfn, &end_pfn); > > if (ret) > > return ret; > > @@ -428,6 +432,8 @@ ssize_t page_idle_proc_generic(struct file *file, char __user *ubuff, > > walk.private = &priv; > > walk.mm = mm; > > > > + lru_add_drain_all(); > > + > > down_read(&mm->mmap_sem); > > > > /* > > -- > > 2.22.0.770.g0f2c4a37fd-goog > > -- > Michal Hocko > SUSE Labs