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=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 3D407C2D0E8 for ; Wed, 1 Apr 2020 01:11:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E18832063A for ; Wed, 1 Apr 2020 01:11:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E18832063A 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 469176B0032; Tue, 31 Mar 2020 21:11:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 419296B0037; Tue, 31 Mar 2020 21:11:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 307586B006C; Tue, 31 Mar 2020 21:11:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0212.hostedemail.com [216.40.44.212]) by kanga.kvack.org (Postfix) with ESMTP id 15EB86B0032 for ; Tue, 31 Mar 2020 21:11:19 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id BFE8F8248047 for ; Wed, 1 Apr 2020 01:11:18 +0000 (UTC) X-FDA: 76657507836.05.hair62_459917782ea2a X-HE-Tag: hair62_459917782ea2a X-Filterd-Recvd-Size: 3026 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Wed, 1 Apr 2020 01:11:18 +0000 (UTC) IronPort-SDR: 7ZcJJ9Sc/FyN5aJtWjE26KQ3onwGaHARgFxBBtSrwhWHO0F+WylQYJgTzZmJF1S5pEWVKmRjJ6 Yx2+iuDSAc2g== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Mar 2020 18:11:16 -0700 IronPort-SDR: gVHqeaoV5DJbZvb07/8/RB7XQ093VpOpw0AdRMNQZPAYpo2I1y2KFXuAf7DRcKt0p2lUe1u+O8 Ru6U8Ow1BCYg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,329,1580803200"; d="scan'208";a="448891586" Received: from yhuang-dev.sh.intel.com (HELO yhuang-dev) ([10.239.159.23]) by fmsmga005.fm.intel.com with ESMTP; 31 Mar 2020 18:11:14 -0700 From: "Huang\, Ying" To: Michal Hocko Cc: Andrew Morton , , , Minchan Kim , "Hugh Dickins" , Rik van Riel Subject: Re: [PATCH] mm, trivial: Simplify swap related code in try_to_unmap_one() References: <20200331084613.1258555-1-ying.huang@intel.com> <20200331094108.GF30449@dhcp22.suse.cz> Date: Wed, 01 Apr 2020 09:11:13 +0800 In-Reply-To: <20200331094108.GF30449@dhcp22.suse.cz> (Michal Hocko's message of "Tue, 31 Mar 2020 11:41:08 +0200") Message-ID: <87tv24j9hq.fsf@yhuang-dev.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii 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: Michal Hocko writes: > On Tue 31-03-20 16:46:13, Huang, Ying wrote: >> From: Huang Ying >> >> Because PageSwapCache() will always return false if PageSwapBacked() returns >> false, and PageSwapBacked() will be check for MADV_FREE pages in >> try_to_unmap_one(). The swap related code in try_to_unmap_one() can be >> simplified to improve the readability. > > My understanding is that this is a sanity check to let us know if > something breaks. Do we really want to get rid of it? Maybe it is not > really useful but if that is the case then the changelog should reflect > this fact. Now the definition of PageSwapCache() is, static __always_inline int PageSwapCache(struct page *page) { #ifdef CONFIG_THP_SWAP page = compound_head(page); #endif return PageSwapBacked(page) && test_bit(PG_swapcache, &page->flags); } So, if PageSwapBacked() returns false, PageSwapCache() will always return false. The original checking, - if (unlikely(PageSwapBacked(page) != PageSwapCache(page))) { is equivalent to - if (unlikely(PageSwapBacked(page) && !PageSwapCache(page))) { Then what is the check !PageSwapBacked() && PageSwapCache() for? To prevent someone to change the definition of PageSwapCache() in the future to break this? Best Regards, Huang, Ying