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=-14.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham 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 4D20DC10DCE for ; Fri, 13 Mar 2020 19:34:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F0E5B206B1 for ; Fri, 13 Mar 2020 19:34:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="I2DYXq4w" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F0E5B206B1 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7A0B36B0003; Fri, 13 Mar 2020 15:34:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 751436B0006; Fri, 13 Mar 2020 15:34:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 666BE6B0007; Fri, 13 Mar 2020 15:34:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0242.hostedemail.com [216.40.44.242]) by kanga.kvack.org (Postfix) with ESMTP id 4C9D16B0003 for ; Fri, 13 Mar 2020 15:34:03 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 015C0180AD830 for ; Fri, 13 Mar 2020 19:34:03 +0000 (UTC) X-FDA: 76591339566.26.wax58_636ad3d78b37 X-HE-Tag: wax58_636ad3d78b37 X-Filterd-Recvd-Size: 7368 Received: from mail-oi1-f193.google.com (mail-oi1-f193.google.com [209.85.167.193]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Fri, 13 Mar 2020 19:34:02 +0000 (UTC) Received: by mail-oi1-f193.google.com with SMTP id a22so10629253oid.13 for ; Fri, 13 Mar 2020 12:34:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Wb4/KS6+9uhEG0B4TwSigcUJLPiMeOYxLqlueo3jlPY=; b=I2DYXq4wlPraz2yYvmEBl6cJPy+kZcx9eML4K5Lu6Ymfoj4Vt+HtkujwCjlRvMMXjO Mu11l0fUPAK2FeIrPyU+VrCFEAUnyO2zIJpGosjgBSID4zNAlPWlIzVDER9bSOtK6eoB Tm2MQK2sUPrxjtCM+2CLduS0jF0aLXeFsGZiqyLP86hPmZF7fHSTciMfgnZb99X457A/ rIm7nlzzRk6dKKj9f5bny7/RNNsVgjbo7RmexmwtNQf6BmOFHdDoMI3JJDRqTmkXpCiH h8670GqFZEtAQDKQgUr4fkL4JZjPYk8dhFwSK9nL4EqvPVFrcLSkIEG473+VuH2xAz2Z D1Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Wb4/KS6+9uhEG0B4TwSigcUJLPiMeOYxLqlueo3jlPY=; b=GfnaCfV64ipyPrrpVQ/VrqT6YC9laejnjXwqDDz1gSq9MLPbruafg1+Mk8FA84BtGu +kqXzPwgQJqh1aXzDIOO5iPMy74p8CruP/pj2gnNV40TosL2q0SuVFOdu7DjdKZxAkPQ ehgyEQIALdFMZYftNi29qYmaP6qXTLDYOQ5SJAWM3gYBmI3O7T3m3aBcMKW3pCAVy5U6 0PPXXIwINBAPnBgG0wPSkF6s6TRxpTsftKlmG6Bfz4Lj5a2qv6qTsJNI9Yos7Avs4N7U lxAuohjc8CaVEEs+xXJfdVd2ZHbL9hZf1QHVFj2H+N8AM1H467TJoj9Af94f2o/y6ioD lDew== X-Gm-Message-State: ANhLgQ2w0zrIxuPuyIKnoDl8AVSNS//sTIC/MRMQ2LuIhR/1hcshO3lo ATL582ZvuWa5qk/0wHhZMGfTicjgTZAuuaaUOLClKw== X-Google-Smtp-Source: ADFU+vuZ7tGVbK62NPw97jFsj8xgjZ9obwM2nBww/pDbRIMb+cNXkiwCRmQtfT+Jdaj9kGjLblHNmHEiFu8cj13Xe/w= X-Received: by 2002:aca:af93:: with SMTP id y141mr8043044oie.144.1584128041488; Fri, 13 Mar 2020 12:34:01 -0700 (PDT) MIME-Version: 1.0 References: <1584124476-76534-1-git-send-email-yang.shi@linux.alibaba.com> In-Reply-To: <1584124476-76534-1-git-send-email-yang.shi@linux.alibaba.com> From: Shakeel Butt Date: Fri, 13 Mar 2020 12:33:50 -0700 Message-ID: Subject: Re: [PATCH 1/2] mm: swap: make page_evictable() inline To: Yang Shi Cc: Vlastimil Babka , Andrew Morton , Linux MM , LKML Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Mar 13, 2020 at 11:34 AM Yang Shi wrote: > > When backporting commit 9c4e6b1a7027 ("mm, mlock, vmscan: no more > skipping pagevecs") to our 4.9 kernel, our test bench noticed around 10% > down with a couple of vm-scalability's test cases (lru-file-readonce, > lru-file-readtwice and lru-file-mmap-read). I didn't see that much down > on my VM (32c-64g-2nodes). It might be caused by the test configuration, > which is 32c-256g with NUMA disabled and the tests were run in root memcg, > so the tests actually stress only one inactive and active lru. It > sounds not very usual in mordern production environment. > > That commit did two major changes: > 1. Call page_evictable() > 2. Use smp_mb to force the PG_lru set visible > > It looks they contribute the most overhead. The page_evictable() is a > function which does function prologue and epilogue, and that was used by > page reclaim path only. However, lru add is a very hot path, so it > sounds better to make it inline. However, it calls page_mapping() which > is not inlined either, but the disassemble shows it doesn't do push and > pop operations and it sounds not very straightforward to inline it. > > Other than this, it sounds smp_mb() is not necessary for x86 since > SetPageLRU is atomic which enforces memory barrier already, replace it > with smp_mb__after_atomic() in the following patch. > > With the two fixes applied, the tests can get back around 5% on that > test bench and get back normal on my VM. Since the test bench > configuration is not that usual and I also saw around 6% up on the > latest upstream, so it sounds good enough IMHO. > > The below is test data (lru-file-readtwice throughput) against the v5.6-rc4: > mainline w/ inline fix > 150MB 154MB > What is the test setup for the above experiment? I would like to get a repro. > With this patch the throughput gets 2.67% up. The data with using > smp_mb__after_atomic() is showed in the following patch. > > Fixes: 9c4e6b1a7027 ("mm, mlock, vmscan: no more skipping pagevecs") > Cc: Shakeel Butt > Cc: Vlastimil Babka > Signed-off-by: Yang Shi > --- > include/linux/swap.h | 24 +++++++++++++++++++++++- > mm/vmscan.c | 23 ----------------------- > 2 files changed, 23 insertions(+), 24 deletions(-) > > diff --git a/include/linux/swap.h b/include/linux/swap.h > index 1e99f7a..297eb66 100644 > --- a/include/linux/swap.h > +++ b/include/linux/swap.h > @@ -374,7 +374,29 @@ extern unsigned long mem_cgroup_shrink_node(struct mem_cgroup *mem, > #define node_reclaim_mode 0 > #endif > > -extern int page_evictable(struct page *page); > +/* > + * page_evictable - test whether a page is evictable > + * @page: the page to test > + * > + * Test whether page is evictable--i.e., should be placed on active/inactive > + * lists vs unevictable list. > + * > + * Reasons page might not be evictable: > + * (1) page's mapping marked unevictable > + * (2) page is part of an mlocked VMA > + * > + */ > +static inline int page_evictable(struct page *page) > +{ > + int ret; > + > + /* Prevent address_space of inode and swap cache from being freed */ > + rcu_read_lock(); > + ret = !mapping_unevictable(page_mapping(page)) && !PageMlocked(page); > + rcu_read_unlock(); > + return ret; > +} > + > extern void check_move_unevictable_pages(struct pagevec *pvec); > > extern int kswapd_run(int nid); > diff --git a/mm/vmscan.c b/mm/vmscan.c > index 8763705..855c395 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -4277,29 +4277,6 @@ int node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned int order) > } > #endif > > -/* > - * page_evictable - test whether a page is evictable > - * @page: the page to test > - * > - * Test whether page is evictable--i.e., should be placed on active/inactive > - * lists vs unevictable list. > - * > - * Reasons page might not be evictable: > - * (1) page's mapping marked unevictable > - * (2) page is part of an mlocked VMA > - * > - */ > -int page_evictable(struct page *page) > -{ > - int ret; > - > - /* Prevent address_space of inode and swap cache from being freed */ > - rcu_read_lock(); > - ret = !mapping_unevictable(page_mapping(page)) && !PageMlocked(page); > - rcu_read_unlock(); > - return ret; > -} > - > /** > * check_move_unevictable_pages - check pages for evictability and move to > * appropriate zone lru list > -- > 1.8.3.1 >