From patchwork Thu Dec 21 22:12:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13502713 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 205FAC35274 for ; Thu, 21 Dec 2023 22:12:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B05C16B0083; Thu, 21 Dec 2023 17:12:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AB5B86B0085; Thu, 21 Dec 2023 17:12:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9A4C76B0087; Thu, 21 Dec 2023 17:12:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 8C5BC6B0083 for ; Thu, 21 Dec 2023 17:12:32 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 569C41C15B5 for ; Thu, 21 Dec 2023 22:12:32 +0000 (UTC) X-FDA: 81592225344.24.0A91645 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf19.hostedemail.com (Postfix) with ESMTP id 601D71A0011 for ; Thu, 21 Dec 2023 22:12:30 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=nYdhVfrq; dmarc=none; spf=none (imf19.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703196750; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=kNtoUlpawoz4nA4ge7DMJMM3XfaoysWgaDBrpCBGE+c=; b=AfuWs46J7/hPgmayYBlvAdS1NsuVG7Dw+yZC5aNf6ghuuLhjvENhPOhjjMmyEx7SxwBErS PuMc9w0IHmr7mQo6DcLQjy2JXqmGf40gYFXQTT+LU/+QmMLdsB7Olkdpzy9JfTQq69kZip CC278so0mFm3pAb6FbSxnkmyNF+kmvc= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=nYdhVfrq; dmarc=none; spf=none (imf19.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703196750; a=rsa-sha256; cv=none; b=sNYMAhZVA4z5TlHbK90E1RufNve0cVhf16IQKACf1M9qYwz+/kTZ56HHwIFTJVkaZG1vie 4wm7Tc/UGYcBTHtsvfKMQjncBVQG0sTyKFrhVv7fKZscA2+I0VSjkc6lnUpCPLozrjihwR bHtj2cgwycEnBVRQFSSp/8fMDKz6s5E= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=kNtoUlpawoz4nA4ge7DMJMM3XfaoysWgaDBrpCBGE+c=; b=nYdhVfrqc821EWydzTBN++lHPb YcmjHqHO27DK+6ZCimocHmUOz2/PePPmKO+bxJmZv/Fb9CBUiIS1NjAxaA9NwEoRDWu3H8lci+Ae7 SbNski4TiH1YlJmcesNZAiJFy4NAMfCpBW0aaYF+VwX78KXRLUDSbPktHTd3ZdHNKSVSlwmsBaqbw acdgNE5Zi5V0Y1kv15jo5MdncEi7pao8nN0vQtCxOs0PUcqMkxazuQ0hR7oGApSl3E65IpMZg1Q2l iFKqAwWYDNrXHx7qANQ4ETPy7ACYZlMlfIlCHV8B/hn/q4L4fho/jSAG1o/n9xxM1ekfqtfBxvy86 lVAgOWXA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rGRHH-006J0O-AX; Thu, 21 Dec 2023 22:12:27 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton , linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , David Hildenbrand , kernel test robot Subject: [PATCH] mm: Fix do_swap_page when KSM is not involved Date: Thu, 21 Dec 2023 22:12:25 +0000 Message-Id: <20231221221225.1502975-1-willy@infradead.org> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 X-Rspamd-Queue-Id: 601D71A0011 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: fmnjynb4cqn37cyi9uh5tzjoh4qqk79i X-HE-Tag: 1703196750-761321 X-HE-Meta: U2FsdGVkX1+W4S64xMSw4eWLQ0I6C4sfoiOKKM8k9Bj7ZeTpgNIGRgC8f4ClGAdM207K5xiqYbSgP8SyAFPlGrf1U8pJjPMBPevngf/Cr0pxP8WPBkE1+qaYA9GPLsxrdNjSMicWXDHhrUEZnnVrKzRJiGInUE3CxoMNAQALRfa/reOuc6PZm2n7qdt/HBfjuYy5/itufa+LdMAhtnRh1/e3iLMv1xJOPf5O5fh3AhLUPQl5rDNFu+Zzxs1prcv6L6jdfDK4ROvbuViyX0W/W86doPDW30cYLCRUrZHbcxzJhV3ddmahQxF36L2iwFo3qxhSRTNdRXbIA0ijLGRWqOjR5Vqo3UKUz7vmFqKSV8SdVkKjQyGpAKblGjWP0EBNu5sE6h4h8m9vJGrPrVTowqG84nHQt3u+vwo819gDMFRTP9sOlKWK76V7bNvY1JtAi2AQzwioxFV/0+BDCpCOCAPChaM2iOmegw1fIANoG+ozvfH9vJwDJ6HWv2u+IdZNfjfEKGlyrL+CYTOPjlVze62E8fsXi+cPjte0K7CJnaImyo+t1o4ODUj/nZSw3hzBOYpYXMJwNheP5DkXxGAKQy3F/oRyOp8rYcC+2vXzWO97Ji3qeuVvyB5Z+wneaYpK/QHom8LgrTpXQhl69kPv5q0pnPaEVdOB/4yfr3diDUak+58DqDpzppnOoypIF9x+r+vH+RwdIYxDg579JvO0k9XOjpflZ1Rzyd+p6tN0cDf8cPm/ZtkrTLSRw8X8py7GaJ8dAvvcvZu7Pk8AR0DVjY5dBvg3dkOMTX6nwbgOHIJIyqPeVVw+6cJvQiqZ5VxIJzSQcl/mOOuJ9IXTs/kKgkGLdhLZ8Rs6OTQbeuI2jqPnW+YLIpaDMigI3omzea37zRewYkV8P3Su6T0DI/N6O6saUUz5gyqQcSy/ynFoPJbJ19G7Fx8Sb1U4nOj5fxG+N06dOkONbClmYS02coj r4fdmrbP HwEqt9aqCVyolDpF9fuZB09PROAMTT0Y35Gu2is0t9J8ewpEcujEZr1aVhAujxtsHH5GMgiQdSAIimcG6KoQreYADj+T9KczZ42EKnT6GfP1MiXmoFZnFYUHKCeceLcdfZnzYgQOp7zYBRCJtYWQuwj54QhLVNr3FzRDtT2pgVPBMgNAMx/p7kt9RbNnIdHHg6X2PkhxFbn2XP/kWx98QpYPeRFlY+6ucjM+oy9jZumdk30AxrxLoL0BAm+4ZOMDvhtFco5n9L5PGUQ/2eM7FkRF3kUgDs1d0bdrcgtw9FrjBzW5iO7dMl45qM9O9c3HrzJ6ETXOfQ5R/xbI= 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: List-Subscribe: List-Unsubscribe: If we have a large folio in the swapcache and KSM declines to replace the folio, we must not recalculate the page. Suggested-by: David Hildenbrand Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-lkp/202312192319.fa8f5709-oliver.sang@intel.com Signed-off-by: Matthew Wilcox (Oracle) --- mm/memory.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/memory.c b/mm/memory.c index 6ca8a4518844..1e16f1b8b92d 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3952,7 +3952,8 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) folio = swapcache; goto out_page; } - page = folio_page(folio, 0); + if (folio != swapcache) + page = folio_page(folio, 0); /* * If we want to map a page that's in the swapcache writable, we