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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8CA88C00144 for ; Tue, 2 Aug 2022 01:24:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F21418E0001; Mon, 1 Aug 2022 21:24:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ECF326B0072; Mon, 1 Aug 2022 21:24:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D96E88E0001; Mon, 1 Aug 2022 21:24:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C65976B0071 for ; Mon, 1 Aug 2022 21:24:56 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 98D9A1C6390 for ; Tue, 2 Aug 2022 01:24:56 +0000 (UTC) X-FDA: 79752908592.28.766FCF6 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by imf06.hostedemail.com (Postfix) with ESMTP id E2C861800F3 for ; Tue, 2 Aug 2022 01:24:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659403495; x=1690939495; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=x6ngo09KFtJj089aELQSz1+JdkFMG0KW45Hv53bEcjg=; b=l2/ZaUTamjgyJm1324MdRqlzUtunkEJyvRMP2hIgfGBtjjFa7wUebQ8m NMpMA5QqBo0ftMnMHhcHS4J7GyvM3RM7Rpl5BmUtJ131JuRZbK2VusZ78 vDxa2pXkIpKVog1N2lh2go6ttgvYcewYYvHJRc9n2E9irbW7gpSverZXj 9e+hjpTB52g7ZBB8dD9Kr1q+g4ScTDq6buXePjJv6qmoZzBqT+Qkzgnwn XzQY1/OW3qEwZPdFYkxn/Li2ygoY5xEYZbZywnR4ZZYaFKZSvnaFMWkPw cLFFuKc/18EaJsq609iXiFRauv1HZGp8m2cLURBoam+2PQs2LqAmdDgfI w==; X-IronPort-AV: E=McAfee;i="6400,9594,10426"; a="286852731" X-IronPort-AV: E=Sophos;i="5.93,209,1654585200"; d="scan'208";a="286852731" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Aug 2022 18:24:53 -0700 X-IronPort-AV: E=Sophos;i="5.93,209,1654585200"; d="scan'208";a="578010627" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Aug 2022 18:24:50 -0700 From: "Huang, Ying" To: Peter Xu Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrea Arcangeli , Andrew Morton , "Kirill A . Shutemov" , Nadav Amit , Hugh Dickins , David Hildenbrand , Vlastimil Babka Subject: Re: [PATCH RFC 1/4] mm/swap: Add swp_offset_pfn() to fetch PFN from swap entry References: <20220729014041.21292-1-peterx@redhat.com> <20220729014041.21292-2-peterx@redhat.com> <8735eglkp5.fsf@yhuang6-desk2.ccr.corp.intel.com> Date: Tue, 02 Aug 2022 09:22:52 +0800 In-Reply-To: (Peter Xu's message of "Mon, 1 Aug 2022 18:29:16 -0400") Message-ID: <87czdjjv6b.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b="l2/ZaUTa"; spf=pass (imf06.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.93 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659403496; a=rsa-sha256; cv=none; b=zk6X8NhzINPPlDmTJDEUM1KlSjvwQaWhE6KO1Yq2Qkh/62NIv0PV+w04p99qTDwQT/WbYQ c9r8vfoyiSbKJGz8k5TxiBy7E3CMd6W1sCUrc0QhuaRh02lm3YHZc+QX2x1dzM7ZkFdRIE nF2jRqBV4ZQPV9F/A0xGhLxOr7tfUk0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659403496; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=RXvFDO7EH8tKusiB2sJSaaiP+eBWy09jxZeKXkF1eIU=; b=7iGGB2URP7jkGEr+fPzmiHMHRbxiK+LAvrwG3pnb0bSsfFhoiFYOe/sZo08Tvo32TNuSVG JObda+X11N+WNvVb7ktDvyvCSU2mF+E35x8lhjKE0c+/K6PL0gFdE6CUroTCzRQAkMkaUP qhnjvo2rkzQ79lEh0CHJjXwfSRpPioE= X-Stat-Signature: cskzmos7hdssf5njo3pkz9p6m3gfkssk X-Rspamd-Queue-Id: E2C861800F3 X-Rspam-User: X-Rspamd-Server: rspam05 Authentication-Results: imf06.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b="l2/ZaUTa"; spf=pass (imf06.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.93 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com X-HE-Tag: 1659403494-675264 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: Peter Xu writes: > On Mon, Aug 01, 2022 at 11:13:58AM +0800, Huang, Ying wrote: >> > +/* >> > + * This should only be called upon a pfn swap entry to get the PFN stored >> > + * in the swap entry. Please refers to is_pfn_swap_entry() for definition >> > + * of pfn swap entry. >> > + */ >> > +static inline unsigned long swp_offset_pfn(swp_entry_t entry) >> > +{ >> >> Is it good to call is_pfn_swap_entry() here for debug that can be >> eliminated in the production kernel? > > Sure, I'll add a VM_BUG_ON() there in the next spin. > >> >> > + return swp_offset(entry) & SWP_PFN_MASK; >> > +} >> > + >> > /* check whether a pte points to a swap entry */ >> > static inline int is_swap_pte(pte_t pte) >> > { >> > @@ -369,7 +387,7 @@ static inline int pte_none_mostly(pte_t pte) >> > >> > static inline struct page *pfn_swap_entry_to_page(swp_entry_t entry) >> > { >> > - struct page *p = pfn_to_page(swp_offset(entry)); >> > + struct page *p = pfn_to_page(swp_offset_pfn(entry)); >> > >> > /* >> > * Any use of migration entries may only occur while the >> > @@ -387,6 +405,9 @@ static inline struct page *pfn_swap_entry_to_page(swp_entry_t entry) >> > */ >> > static inline bool is_pfn_swap_entry(swp_entry_t entry) >> > { >> > + /* Make sure the swp offset can always store the needed fields */ >> > + BUILD_BUG_ON(SWP_TYPE_SHIFT < SWP_PFN_BITS); >> >> BUILD_BUG_ON(SWP_TYPE_SHIFT <= SWP_PFN_BITS); > > Logiclaly it's okay to have SWP_TYPE_SHIFT==SWP_PFN_BITS? Sorry, I misunderstood the original code. Please ignore this comment. Best Regards, Huang, Ying