From patchwork Thu Jan 16 21:23:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13942317 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 64C8DC02183 for ; Thu, 16 Jan 2025 21:23:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EFC42280002; Thu, 16 Jan 2025 16:23:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ED26E280001; Thu, 16 Jan 2025 16:23:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D9ACB280002; Thu, 16 Jan 2025 16:23:45 -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 BA6D5280001 for ; Thu, 16 Jan 2025 16:23:45 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 4FA77B07F6 for ; Thu, 16 Jan 2025 21:23:45 +0000 (UTC) X-FDA: 83014592010.24.142C5A8 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf21.hostedemail.com (Postfix) with ESMTP id DF9DA1C0003 for ; Thu, 16 Jan 2025 21:23:42 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=qMbK6yBw; dmarc=none; spf=none (imf21.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=1737062623; a=rsa-sha256; cv=none; b=K21vfJGAVc8oD27fVEnF4xowrlxSAWfStrXm2o0mc19MyOGHxqJhB77ywn7yijNImFKqM1 RnFGJDhC6UKT6fZSSaRxbmXRHxXOKGlXVrMp5c/WJw9YP0aheVv8R9JgNsoYEkeY8ZoxUR /P7B2uA8fy8Z60KV+5JgelNyd5mSgdE= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=qMbK6yBw; dmarc=none; spf=none (imf21.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=1737062623; 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=JcsW0E8R/Af5UZ/71twIUll/13/AWxEfCAZ8p35a4hk=; b=EvX+J3ERjcdIx6npXfttf6lUp+mUP7JZGHNlu5LaLLo3KXbdOxYTebojsHOyQlkijjU0rM 0vB76KHO719wNmm4zyA/BFziePr2HkdO9fLB5T0234HFUpUFkcSeFSmWa3JWTlQDkz3QgE udGHVfpJr6lM6+sDojizONlYrWPj0DI= 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=JcsW0E8R/Af5UZ/71twIUll/13/AWxEfCAZ8p35a4hk=; b=qMbK6yBwdwoqAcLpTK9CE9XV8o yLRgStQI97NgJ0xR8egFxLGpQvCMfgnk6Uk/xbH59PFRSwAIo+t0xdNWPFjGllwUGMRrwFXnToc/+ MbvxH/CTYf+PPETVTSlJDe8WJ71qnf+HQXbEkNCF9XMkmnifprFl0ADqg+yctumi8UK3IGlV0ErT6 Dc6nj6XUqFT0Z1nH8eAhIRP7QwniYizKqlfrtzYign/94TJaTSWUBvKisK9UMNYOt9ynpjuMii/YS CtUHoVkTP7FjeWV/XeKIG4OJasfL+//4Rh8/cKhe3VRKIM3irMwRe64Un4CWrr6kVtYxYm+PXRuM6 cRP06p3Q==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tYXL2-00000002jxm-1c5e; Thu, 16 Jan 2025 21:23:40 +0000 From: "Matthew Wilcox (Oracle)" To: Alexander Gordeev Cc: "Matthew Wilcox (Oracle)" , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Claudio Imbrenda , Christian Borntraeger , linux-mm@kvack.org Subject: [PATCH] s390: Remove PageDirty check inside mk_pte() Date: Thu, 16 Jan 2025 21:23:36 +0000 Message-ID: <20250116212338.653160-1-willy@infradead.org> X-Mailer: git-send-email 2.47.1 MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: DF9DA1C0003 X-Stat-Signature: qoe78463b8o1ifon71dp96sznsoyaadi X-Rspam-User: X-HE-Tag: 1737062622-368184 X-HE-Meta: U2FsdGVkX1/EeWu5n2N10wJV0T7yKiep0C11lsgoMCtFHjQzB8JH0diKK9BiLfJLxANTSCpBfj87+lPG7wWkppkM3ynfepJE/uAD/hrGN7tgKC0tqK6C+sHHiJ4R7m2fzu8nje4V8l+ii4JVEV8dNt/sh7ahMmX+Sd8VH/IQP++8DdDAcCcwU/6EgLp3ivA8ENjcV2hSikIv1XKNIuoqSIMFsXZRPpbq90kK1yI7RyFjaddV7Onz0wj+MbFVojksHtTuIBRFwAAZJ3cEyl219MQxf8Zzobq+63BKHnZU5Dg/maSz3v546BC8UStigPq6f9c3F+XyuynphayfS0OIFXs6wJuY1NS+s9OdsJyiAznIdS9vhattOiQvbA8uwBgaiNM6u01kvTYPwXSCPMR73A9zkymnKP2/a0A9G1AQNIwYwJUcEwavuq8+6v2lGAddjsIn01/hc5Se2rXlByawyq98UYWUCOHF1weZ6rjaBZ80cL4DZ+zWIPipd8xSKev1ouWjyPrCYSnrOBzWIrIBimaGfJxHKNeN+8/P1ulW06xX9SSFxEkzSlBPm+XM974EAljl4z/lpvHlRDocI9XZQaXdfuzxPZZSCkZfWWTshIPwN34IQhuxGjjkjf8YueRE7gAuucfy/LnmRbKqrXJBL3CUXwMXvj4mLe/Bb4AaE+JBXcaeCrxeHnx8oF53e5TvDh/PvBlSy65X8DNw+28fR2DWliwZ7pJYQauJrZN4qPA25B2yKQCspF/5tEsFBj37hFkWz86aVRQ83OuF1Ow9+arDQspnec6ooY6eamhTf5H8tollMxlClZ/irWajw6FfVU8HKHQZBFxpwKN/h4fnLYghUnh1P0GLvpEQ5rAFaPqJg+hk1uK9K1/g4a0yGy4CZnrvvyC0XLR69HoUqP/w3+Cu93OKP97bOMLC9BkFtisdmWV/DLQFttwPGVIiLGwuL96BYu52hA49VdWFsLo GJk3tkXg eL4qrtC1g2H4ArU/lFjkaO3nJPyu3G/XLaRIyjC9ZTd7Lyq/5LbX1R2aD75j2++09Jb9J+rBKiTbRS6pLtel/9+G5+Cbv3MqxrUGRz7ogP9IYE3aODTN9TxPkuCNR7nv6AZoFm/9bP3n3LDKqg/cGKImc3vk8bWV6P83yW9f+GyfTuoiVle5+dAMNbPIZbYZGogRiZTg9CueG9IZWybA02PA9O0qcuk50U+hkb86UUFnTxVtZLdxZ4F2Ex0oJwCtLlgl5faJyHyN7oFGTzP0+UI0Iw2ojT8/GGa128uXGV3dLMxDa4YPt1RALfw== 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: In commit abf09bed3cce ("s390/mm: implement software dirty bits"), the rationale for adding the PageDirty() test was: To avoid an excessive number of additional faults the mk_pte primitive checks for PageDirty if the pgprot value allows for writes and pre-dirties the pte. That avoids all additional faults for tmpfs and shmem pages until these pages are added to the swap cache. shmem does not mark newly allocated folios as dirty since 2016 (commit 75edd345e8ed) so this test has been ineffective since then. It still triggers for some calls to mk_pte(), but those calls are usually followed with other calls to pte_mkdirty() making the ones inside s390's mk_pte() redundant. Signed-off-by: Matthew Wilcox (Oracle) --- arch/s390/include/asm/pgtable.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) Please check this doesn't cause any real world performance issues. Alexander and I briefly discussed this last year: https://lore.kernel.org/linux-mm/20240814154427.162475-5-willy@infradead.org/ but then I missed his followup on August 22nd, and thought it best to reopen the conversation with a fresh patch to test. diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h index 48268095b0a3..4c7e2fc2b5ff 100644 --- a/arch/s390/include/asm/pgtable.h +++ b/arch/s390/include/asm/pgtable.h @@ -1443,11 +1443,8 @@ static inline pte_t mk_pte_phys(unsigned long physpage, pgprot_t pgprot) static inline pte_t mk_pte(struct page *page, pgprot_t pgprot) { unsigned long physpage = page_to_phys(page); - pte_t __pte = mk_pte_phys(physpage, pgprot); - if (pte_write(__pte) && PageDirty(page)) - __pte = pte_mkdirty(__pte); - return __pte; + return mk_pte_phys(physpage, pgprot); } #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))