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 3DB44C02182 for ; Mon, 20 Jan 2025 16:40:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 694576B0083; Mon, 20 Jan 2025 11:39:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 643FE6B0085; Mon, 20 Jan 2025 11:39:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 50D606B0088; Mon, 20 Jan 2025 11:39:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 3517A6B0083 for ; Mon, 20 Jan 2025 11:39:59 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id B89A7A02A2 for ; Mon, 20 Jan 2025 16:39:58 +0000 (UTC) X-FDA: 83028392076.27.3C05D9E Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf02.hostedemail.com (Postfix) with ESMTP id 7CB6880002 for ; Mon, 20 Jan 2025 16:39:56 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=TsFBr7ZL; spf=pass (imf02.hostedemail.com: domain of agordeev@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=agordeev@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1737391196; 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=Nsz5T0lPcmYlw+oPC8l10B1POszB0p33SacnbsH7DZo=; b=7Zpc2tV3G9vZlMShJgmA5lc2vy9PeadKNqYULCPu12AP+Y99MKBUmWuxlHWs8aSOQpDVq/ eZHT+JFuQyQK5lV+UYnlLiCH2tq/x+27gIgvAicsuh7MBsa//IJReIGFw5+HUdL0tGfC9s rP90xOyUZ4IGwEaGwehwnAPNpvZpCWI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737391196; a=rsa-sha256; cv=none; b=u8cb2J1M0E/RMIYy8h6s9+FXNOa4JyJQBzmdxV/y2mcg2ijz94UlTZ47d65oYknVZJQ5lL 1nz6z8lCWkp+j/8xeUgixdftR6CbZ/ey9fbx56kx1dFCefCjG2laxcYPmAWjvRCWfV2MWZ OwKK7Md32xDLTaV1h5FKfqUNwsNccXY= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=TsFBr7ZL; spf=pass (imf02.hostedemail.com: domain of agordeev@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=agordeev@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50KF8E7Z003462; Mon, 20 Jan 2025 16:39:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to; s=pp1; bh=Nsz5T0lPcmYlw+oPC8l10B1POszB0p 33SacnbsH7DZo=; b=TsFBr7ZLBmGsqWWVMTkh011d0eQRIcHC8oluXfJd903IDK gSWwlaJhNEZ07Q3MWF7lhXk0oPm7h5CRSXwVL7tDj/qtuNj7yI5Jz/EZR67WG3Mh VIasI3pouHkRF/gqTTxn/NO9DC6HlpbLAILygW2Tqo+4wu9T3F0i8tkexU5n/BHd LL3gaIJkJZu+IzYy5iGbTGTzk32VcJ8hrTHIeMpZow9xtUy+WJpHz5nbCqvaEKeV GbeIrLRg76a3ycqLbzhEd4hWHvjGoAUyo5C/G91CLFjayf/QU9/VownYeRDieN1F DQOEHO3RTxMGViiLJ2QISPLTE7HSpxH8QRcBFnCg== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 449ga7ax5b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jan 2025 16:39:50 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 50KFfk1n029553; Mon, 20 Jan 2025 16:39:49 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 448qmn76ay-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jan 2025 16:39:49 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 50KGdj0v54198568 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 Jan 2025 16:39:45 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8FE5420043; Mon, 20 Jan 2025 16:39:45 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1F3E720040; Mon, 20 Jan 2025 16:39:45 +0000 (GMT) Received: from li-008a6a4c-3549-11b2-a85c-c5cc2836eea2.ibm.com (unknown [9.171.12.225]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTPS; Mon, 20 Jan 2025 16:39:45 +0000 (GMT) Date: Mon, 20 Jan 2025 17:39:43 +0100 From: Alexander Gordeev To: "Matthew Wilcox (Oracle)" Cc: Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Claudio Imbrenda , Christian Borntraeger , linux-mm@kvack.org Subject: Re: [PATCH] s390: Remove PageDirty check inside mk_pte() Message-ID: References: <20250116212338.653160-1-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250116212338.653160-1-willy@infradead.org> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: FP6s9EqDwG41wGrMZyo7osa2oI_TjXf3 X-Proofpoint-GUID: FP6s9EqDwG41wGrMZyo7osa2oI_TjXf3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-20_04,2025-01-20_03,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 mlxscore=0 impostorscore=0 suspectscore=0 clxscore=1015 spamscore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 adultscore=0 phishscore=0 mlxlogscore=414 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2501200136 X-Rspamd-Queue-Id: 7CB6880002 X-Stat-Signature: u9kqm1rsrtfqtro96fpxh9etdc6tpxwt X-Rspam-User: X-Rspamd-Server: rspam12 X-HE-Tag: 1737391196-75654 X-HE-Meta: U2FsdGVkX19/q205yH3DCD4avWKWvsUIh2LVnAPhDJ1k7JYKo8gpFMTod5xWn66Jgy9STwVEUcB+bqepy+OmN47p5H8dl8s5SBfa/WOd1beajgrdSnrszE1NYUFsCfTMODWlnj1m46PeDcSpp0BCD6JLEb0QdfIuto2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/v7k548LpPkm1yro1fzta/9dSUr9rHHVImLlvG+wRyD8Dv1GuUlXZzf+1SL+lqJ9V1Mx3COeCDJVdn3VFp3FMAaay8dueUaa85Hz8FKCZ 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: On Thu, Jan 16, 2025 at 09:23:36PM +0000, Matthew Wilcox (Oracle) wrote: Hi Matthew, > 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. I tried to take exactly this approach last year, but dropped the ball. Despite the commit 75edd345e8ed claim above I still observed that a read access to shmem page could end up in creation of a dirty PTE: handle_pte_fault() -> do_pte_missing() -> do_fault() -> do_read_fault() -> finish_fault() -> set_pte_range() -> mk_pte() Our internal discussion (among other things) ended up in a need to really understand where the faults are coming from. Further, a cursory LTP test was showing ~18K page faults increase, which I did not confirm. That is the first thing I will re-do. Whether this change is a pre-requisite for something or what is your aim wrt to this patch? > 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)) Thanks!