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=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable 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 1B5CFC18E5A for ; Wed, 11 Mar 2020 01:12:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C701120727 for ; Wed, 11 Mar 2020 01:12:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C701120727 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7175B6B0003; Tue, 10 Mar 2020 21:12:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6C76C6B0006; Tue, 10 Mar 2020 21:12:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 604696B0007; Tue, 10 Mar 2020 21:12:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0162.hostedemail.com [216.40.44.162]) by kanga.kvack.org (Postfix) with ESMTP id 47E7E6B0003 for ; Tue, 10 Mar 2020 21:12:09 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 13FDF814B for ; Wed, 11 Mar 2020 01:12:09 +0000 (UTC) X-FDA: 76581305178.10.scent61_12aca4b306f3f X-HE-Tag: scent61_12aca4b306f3f X-Filterd-Recvd-Size: 4596 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Wed, 11 Mar 2020 01:12:08 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Mar 2020 18:12:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,539,1574150400"; d="scan'208";a="415398543" Received: from yhuang-dev.sh.intel.com ([10.239.159.23]) by orsmga005.jf.intel.com with ESMTP; 10 Mar 2020 18:12:02 -0700 From: "Huang, Ying" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , David Hildenbrand , David Rientjes , Michal Hocko , Dave Hansen , Mel Gorman , Vlastimil Babka , Minchan Kim , Johannes Weiner , Hugh Dickins , Rik van Riel Subject: [PATCH] mm: Add more comments for MADV_FREE Date: Wed, 11 Mar 2020 09:11:17 +0800 Message-Id: <20200311011117.1656744-1-ying.huang@intel.com> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: From: Huang Ying To help people understand the MADV_FREE code, especially the page flag, PG_swapbacked. Signed-off-by: "Huang, Ying" Suggested-by: David Hildenbrand Cc: David Rientjes Cc: Michal Hocko Cc: Dave Hansen Cc: Mel Gorman Cc: Vlastimil Babka Cc: Minchan Kim Cc: Johannes Weiner Cc: Hugh Dickins Cc: Rik van Riel --- include/linux/mm_inline.h | 9 +++++---- include/linux/page-flags.h | 4 ++++ mm/swap.c | 6 +++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h index 6f2fef7b0784..01144dd02a5f 100644 --- a/include/linux/mm_inline.h +++ b/include/linux/mm_inline.h @@ -9,10 +9,11 @@ * page_is_file_cache - should the page be on a file LRU or anon LRU? * @page: the page to test * - * Returns 1 if @page is page cache page backed by a regular filesystem, - * or 0 if @page is anonymous, tmpfs or otherwise ram or swap backed. - * Used by functions that manipulate the LRU lists, to sort a page - * onto the right LRU list. + * Returns 1 if @page is page cache page backed by a regular filesystem = or + * anonymous page lazily freed (e.g. via MADV_FREE). Returns 0 if @page= is + * normal anonymous page, tmpfs or otherwise ram or swap backed. Used b= y + * functions that manipulate the LRU lists, to sort a page onto the righ= t LRU + * list. * * We would like to get this info without a page flag, but the state * needs to survive until the page is last deleted from the LRU, which diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 49c2697046b9..992b71c4fc85 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -63,6 +63,10 @@ * page_waitqueue(page) is a wait queue of all tasks waiting for the pag= e * to become unlocked. * + * PG_swapbacked is cleared if the page is page cache page backed by a r= egular + * file system or anonymous page lazily freed (e.g. via MADV_FREE). It = is set + * if the page is normal anonymous page, tmpfs or otherwise RAM or swap = backed. + * * PG_uptodate tells whether the page's contents is valid. When a read * completes, the page becomes uptodate, unless a disk I/O error happene= d. * diff --git a/mm/swap.c b/mm/swap.c index 6a8be910b14d..90bb14695809 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -573,9 +573,9 @@ static void lru_lazyfree_fn(struct page *page, struct= lruvec *lruvec, ClearPageActive(page); ClearPageReferenced(page); /* - * lazyfree pages are clean anonymous pages. They have - * SwapBacked flag cleared to distinguish normal anonymous - * pages + * Lazyfree pages are clean anonymous pages. They + * have PG_swapbacked flag cleared, to distinguish + * them from normal anonymous pages */ ClearPageSwapBacked(page); add_page_to_lru_list(page, lruvec, LRU_INACTIVE_FILE); --=20 2.25.0