Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp14337ybh; Tue, 10 Mar 2020 18:13:49 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvY+xoI+6TpSIwHz8zsRJX/PcWnGiLLMVdGgGATLLPQ8MCOhfky9nBCv6MGcogds/K3WSGy X-Received: by 2002:a54:4085:: with SMTP id i5mr321501oii.17.1583889229512; Tue, 10 Mar 2020 18:13:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583889229; cv=none; d=google.com; s=arc-20160816; b=d3lcsS0TGJUei7Ot1fYjMgNZ9mpO0YYyfQf1rolDl+IOPGNMHv/VBOq52apLJMT7Hg UG+f5l/hFZdyCWdHngNg620CuybIdcPHHjX9x4nnEqPSWfY+MFkXQOIBcWqXam9GlXMc Kwf37qe0WnOyRHQOj+b/+vD9JWqv3AvrQdvEifeHuTrH4LMyZXMbuj9nriOnJuJgX42h 8jxSen6jpOKRSO2Tn3+lsUQStUZhXcHTvljH6jo7z/ZA46vSHTKNGHhhrNmO5ciWCKaP EgpLCgtglu/taLeub64XSVuQWfOTzpM57Mr7wi8igqQ75u60m8xPY4wbM9e4TMKJwLPL GmYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=2jW79bHIMxlqLG0Rr4CBZ8XeuE0YB2HPh/xSFBN24xE=; b=thaxu4+28dEM1LfAstnrDVQBcFiE15OMAP3BAkgotbv8osQ+Y8iaUd+fG7dz5cxTyI axZI4Vtc7pWW3Zpu+TTzwLZTbWkJqdSNpgzQ1i/pLeqog1hMkb4lhyTnInqsX3q7pheQ Jv8lHdb719S7kbmHdKBDl2oeRyz+EhfBHCWKldANbtJQVMjjMJs7gmy0V4likzcrE/0O XhzLVJ/QtuVqUkN2JE0UpzMLGpLJO3/XYVLMZGeo8QOZWU5Rt2iZePAtvTjWhEEys98e DUiPEerItd7nRQFLSx0qRiZyoD5m/y5+dj8N+y64+6Wh72HzEh99GKrZizy/H+6LYvt0 pTXg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v21si208358otp.189.2020.03.10.18.13.27; Tue, 10 Mar 2020 18:13:49 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727841AbgCKBMG (ORCPT + 99 others); Tue, 10 Mar 2020 21:12:06 -0400 Received: from mga14.intel.com ([192.55.52.115]:6130 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727528AbgCKBMG (ORCPT ); Tue, 10 Mar 2020 21:12:06 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.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: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 by + * functions that manipulate the LRU lists, to sort a page onto the right 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 page * to become unlocked. * + * PG_swapbacked is cleared if the page is page cache page backed by a regular + * 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 happened. * 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); -- 2.25.0