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 DAD19C28CF5 for ; Wed, 26 Jan 2022 14:25:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 636AA6B0075; Wed, 26 Jan 2022 09:25:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E54F6B0078; Wed, 26 Jan 2022 09:25:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4AC736B007B; Wed, 26 Jan 2022 09:25:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0128.hostedemail.com [216.40.44.128]) by kanga.kvack.org (Postfix) with ESMTP id 39B116B0075 for ; Wed, 26 Jan 2022 09:25:56 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id F0FA893D75 for ; Wed, 26 Jan 2022 14:25:55 +0000 (UTC) X-FDA: 79072662270.10.3ED8119 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf11.hostedemail.com (Postfix) with ESMTP id 7EEBD40002 for ; Wed, 26 Jan 2022 14:25:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=LiOUw0BmLOCV5aXkbkiAQ3Ht3cRjDO/swK3bGS2AZxs=; b=oItQVVFfHwr0aOvBCsF7zp4OOi RFvfZJkzhP/JdBpwYViRO401Z2hBTt55jxtY0F2cslTDw6q2mG0oyGyu7iOM1jx1/WEQ0Xgh7jdA4 rWMMGVggmGVjGDX9Aua0BQqGKZZnJlhHs+kmhvPXV98ap+1Rrmo3/5MwrSiJjsMDjx19u3l4RoKcn 2MRT+3t6Sp5FeFR6X+O4aPj9y0eekKjlz5KV9uauRg3/ubAMubGjDzEZzESs0oZUAg9zadZvAqhME FPh6YqRM3qqH6QFsA+Ebb8xNtA5oaRmpcOSELzy4WV7bX+BFwI3C9ULl58xtmhnk7EXPzBoTuRzeo aBgzAS0g==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nCjEj-0047J8-Qd; Wed, 26 Jan 2022 14:25:25 +0000 Date: Wed, 26 Jan 2022 14:25:25 +0000 From: Matthew Wilcox To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, Andrew Morton , Hugh Dickins , Linus Torvalds , David Rientjes , Shakeel Butt , John Hubbard , Jason Gunthorpe , Mike Kravetz , Mike Rapoport , Yang Shi , "Kirill A . Shutemov" , Vlastimil Babka , Jann Horn , Michal Hocko , Nadav Amit , Rik van Riel , Roman Gushchin , Andrea Arcangeli , Peter Xu , Donald Dutile , Christoph Hellwig , Oleg Nesterov , Jan Kara , Liang Zhang , linux-mm@kvack.org, Nadav Amit Subject: Re: [PATCH RFC v2 1/9] mm: optimize do_wp_page() for exclusive pages in the swapcache Message-ID: References: <20220126095557.32392-1-david@redhat.com> <20220126095557.32392-2-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220126095557.32392-2-david@redhat.com> X-Stat-Signature: 4qh7a5d57am9o6tk1wgzpngwxowfta6d X-Rspam-User: nil Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=oItQVVFf; spf=none (imf11.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 7EEBD40002 X-HE-Tag: 1643207155-660652 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: On Wed, Jan 26, 2022 at 10:55:49AM +0100, David Hildenbrand wrote: > Liang Zhang reported [1] that the current COW logic in do_wp_page() is > sub-optimal when it comes to swap+read fault+write fault of anonymous > pages that have a single user, visible via a performance degradation in > the redis benchmark. Something similar was previously reported [2] by > Nadav with a simple reproducer. > > Let's optimize for pages that have been added to the swapcache but only > have an exclusive owner. Try removing the swapcache reference if there is > hope that we're the exclusive user. > > We will fail removing the swapcache reference in two scenarios: > (1) There are additional swap entries referencing the page: copying > instead of reusing is the right thing to do. > (2) The page is under writeback: theoretically we might be able to reuse > in some cases, however, we cannot remove the additional reference > and will have to copy. > > Further, we might have additional references from the LRU pagevecs, > which will force us to copy instead of being able to reuse. We'll try > handling such references for some scenarios next. Concurrent writeback > cannot be handled easily and we'll always have to copy. > > While at it, remove the superfluous page_mapcount() check: it's > implicitly covered by the page_count() for ordinary anon pages. > > [1] https://lkml.kernel.org/r/20220113140318.11117-1-zhangliang5@huawei.com > [2] https://lkml.kernel.org/r/0480D692-D9B2-429A-9A88-9BBA1331AC3A@gmail.com > > Reported-by: Liang Zhang > Reported-by: Nadav Amit > Signed-off-by: David Hildenbrand Reviewed-by: Matthew Wilcox (Oracle)