Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp3968796ybh; Tue, 6 Aug 2019 04:20:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqyG4iHazAUT/Lk7aY1zG2PjIOyOp1OnSDV2H0exmoztkz8SiAG/d44NU7XgbxA/UhA3asZT X-Received: by 2002:a17:90a:d817:: with SMTP id a23mr2658913pjv.54.1565090451279; Tue, 06 Aug 2019 04:20:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565090451; cv=none; d=google.com; s=arc-20160816; b=y9S+GMoJfqqKhb96Onup+JW+y54JvmbAYOL+HK5QJ7sbVEl6zMS2ASEWfGIzM5Cis8 OCvyJTGtOgCTC674BX8jSlseQYJ+qNxDxbRD76MRzBzD7jVHVMuw8I3g2mxnUQVg4HER bQQRGPPm6dCrmWaTAgYDuy/Za0mnJeukq+vM0QHJflt0syStt3R7f4nXDtEB9ro6RwHx 1pliur6jIsiY2teVN3Z056v55Nr9DJUYXVC2z1yV8vyEL+Sc8rsbaztRWsBkD+l+yU69 BNMdiy6oUu5vw4bI+l/mOFLljJGafP/vbDf5xeHVEo7k3m495EsL2Suvtf6SgynZvArT ZfTg== 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=jNBh4Uwy6QLd0fk5I8Y9B9xP/9fw2xkjlyVlCT+yndM=; b=gKhtZF083bcRSzBuht5zvYUprkekcISERpNS0aBHYQG7Cj9d8LhpmMrVOxZVHReBIG RcmA4o3u/E+uoE2nCY+wa7W3UzTpbPoVxghzOlAYTQjoUZCYs2LToy7G/UoTKXaDMMl5 mSQUcHVas/eL9RWifZPfbynbYnSyLdn0pfpH4sJSk1wT/7fcbmJG30EKHhEVT0U2qpyg dzUNyNbsqTaine3JyjLBgaSNsi6AlfsCZSSsmSE7WdHgDEvSOaAbWniqWOffyV71rUv/ INyjGWaj+XnO+s+Fu97U2H4zc5o0Rck5rHFektFCOQfHAOulnOfh7dGzYVWK8vqwOpj/ Ujdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b="hT7m/kPE"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d4si49247102pgm.357.2019.08.06.04.20.35; Tue, 06 Aug 2019 04:20:51 -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=pass header.i=@joelfernandes.org header.s=google header.b="hT7m/kPE"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732894AbfHFLT1 (ORCPT + 99 others); Tue, 6 Aug 2019 07:19:27 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:44200 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732883AbfHFLTY (ORCPT ); Tue, 6 Aug 2019 07:19:24 -0400 Received: by mail-pf1-f194.google.com with SMTP id t16so41311283pfe.11 for ; Tue, 06 Aug 2019 04:19:24 -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=jNBh4Uwy6QLd0fk5I8Y9B9xP/9fw2xkjlyVlCT+yndM=; b=hT7m/kPEBbfuocAKw5Xl9iF6rszGIOiOU1pdk9Yl9uQaoSvBKVDI9XOMkrfdb7LwCJ TwHeWzeGX8FvyMCo3V+QlzvodG0odf5bOEzj1zCP1QE3OBESAFt9TvXGZ4VZEvsAcJtG tqZe0a8M+Hv2lAOkMv1yerWslMxtF2wkEcWqQ= 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=jNBh4Uwy6QLd0fk5I8Y9B9xP/9fw2xkjlyVlCT+yndM=; b=aZrfRAPUoOOIQ97EeiMGGbJCtwI2tsxhl2754Jg5yH2KF3wWSdY5/8M+KwxzAN8N62 LCFNoE6IsKrhWFzW9qvPKErk+3AJimQi2txk5AV6pdCwjLsnKHfoeuzmFOM43UdlTXDn g9Q98rnyQTitotviYlmid6FUK7dOYwPUYMFCmr+2eQYju3MEm2dI1wi5tw5eXqGSG179 9iDVmubTnGEVwfqXfMVotim2QqKUBr/mjtCkmb+0p4ZvtUaRZ+8bmv4i6TToFx4XI/Li QnGEEznGCaPwITggt6bSAkEqHwt0FiGdQzO7C5t/czcbwMDv+JpoCCIBN6Sh2cYW5UK9 CrGA== X-Gm-Message-State: APjAAAX+ta29LjiMFDm97RmZNuz4qTuA1ifWt/9anXIDKmXhUb07InQd MUngJBwN2n3RUA4VKE8a555Ozw== X-Received: by 2002:a17:90a:c20e:: with SMTP id e14mr2839075pjt.0.1565090363666; Tue, 06 Aug 2019 04:19:23 -0700 (PDT) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id w16sm109123479pfj.85.2019.08.06.04.19.22 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 06 Aug 2019 04:19:22 -0700 (PDT) Date: Tue, 6 Aug 2019 07:19:21 -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: <20190806111921.GB117316@google.com> References: <20190805170451.26009-1-joel@joelfernandes.org> <20190805170451.26009-4-joel@joelfernandes.org> <20190806084357.GK11812@dhcp22.suse.cz> <20190806104554.GB218260@google.com> <20190806105149.GT11812@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190806105149.GT11812@dhcp22.suse.cz> 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 On Tue, Aug 06, 2019 at 12:51:49PM +0200, Michal Hocko wrote: > On Tue 06-08-19 06:45:54, Joel Fernandes wrote: > > 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 belongs to the changelog. Sure, will add. > > 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? > > Can we set the idle bit also for non-lru pages as long as they are > reachable via pte? Not at the moment with the current page idle tracking code. PageLRU(page) flag is checked in page_idle_get_page(). Even if we could set it for non-LRU, the idle bit (page flag) would not be cleared if page is not on LRU because page-reclaim code (page_referenced() I believe) would not clear it. This whole mechanism depends on page-reclaim. Or did I miss your point? thanks, - Joel