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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7096DCAC587 for ; Tue, 9 Sep 2025 09:41:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CD2796B00B1; Tue, 9 Sep 2025 05:41:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C831E6B00B2; Tue, 9 Sep 2025 05:41:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B4AAF6B00B3; Tue, 9 Sep 2025 05:41:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 9C7E36B00B1 for ; Tue, 9 Sep 2025 05:41:11 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 4BFEA160452 for ; Tue, 9 Sep 2025 09:41:11 +0000 (UTC) X-FDA: 83869218342.06.05D9C25 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf04.hostedemail.com (Postfix) with ESMTP id F131840006 for ; Tue, 9 Sep 2025 09:41:08 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b="ERAKr2/0"; spf=pass (imf04.hostedemail.com: domain of agordeev@linux.ibm.com designates 148.163.158.5 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=1757410869; 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=zWcQIXAgSZE3jCftx8qMBMf1VpUurIYqH9HodqEjE0k=; b=lRfSx8EbzR7tZX6aYg+OTr1trjGHzHkgqyEDvty8+cFLVpUHrV49EUPUR4q/7rK01u1lGc k0b/hAB0mcB+VZRHRzb479Ob2fklueGBnhi+/vZWeL5w80nfCtSChtXTcI8YLKHtCJvyjg ifiuXeYfe0TW6FKX9LaajQgxSGbja00= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b="ERAKr2/0"; spf=pass (imf04.hostedemail.com: domain of agordeev@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=agordeev@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1757410869; a=rsa-sha256; cv=none; b=8P2wi1aiYeKsuYjVypTcM13dM//r1HCxQHFJzn+Ba3GOwX8yKBREMPhoNmaHH6QyZUWuGy shS0Qs65s76Mf/xloCHYEvX+ClqnzLE767LHBDC2E61R+x22zjHnnATVgDBDoMHeG9WMUX uIx82ZZfKu4Wj7tiEd5lvlCL5BfTFsI= Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 58983LO1017978; Tue, 9 Sep 2025 09:40:44 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=zWcQIXAgSZE3jCftx8qMBMf1VpUurI YqH9HodqEjE0k=; b=ERAKr2/0b+85Gl0gJGPChBwQF66LW3Oi2PTpVHT0S9O3cT Ogh6Obsb22mSDB6RKtFvicQxQH7Em5A8oD0I5nxAwaNb8/uo3nlQzflgWHoDaI73 HJYbO2EM++BmL63dYswiKyf3DCl4sC43LQKUJvgYSzJoqo9flhIr4HpJX5FgSugx nxkpTZzhMCKXzjU82MrRkLPjYDbZe873Vx7Wql1XT2f1I7N0MW1XZjVRPa59K2LD VV7jPCPICsB1PgyR4Skp/kJKJN0V5UfeoBSNtFq2eg9a3cWAGVbhYaW2tp1HOhpP +lYn2f2O6UcFcD/48WOX69CsC02e71Jd9O9OLeiA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 490acqxs3x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Sep 2025 09:40:44 +0000 (GMT) Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5899HIXj021030; Tue, 9 Sep 2025 09:40:43 GMT 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 490acqxs3v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Sep 2025 09:40:43 +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 5896bOAX008428; Tue, 9 Sep 2025 09:40:42 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 49109pjf7r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Sep 2025 09:40:42 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5899eexO52167112 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 9 Sep 2025 09:40:40 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 604B32004D; Tue, 9 Sep 2025 09:40:40 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8D98620043; Tue, 9 Sep 2025 09:40:38 +0000 (GMT) Received: from li-008a6a4c-3549-11b2-a85c-c5cc2836eea2.ibm.com (unknown [9.87.149.210]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTPS; Tue, 9 Sep 2025 09:40:38 +0000 (GMT) Date: Tue, 9 Sep 2025 11:40:37 +0200 From: Alexander Gordeev To: David Hildenbrand Cc: Kevin Brodsky , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andreas Larsson , Andrew Morton , Boris Ostrovsky , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dave Hansen , "David S. Miller" , "H. Peter Anvin" , Ingo Molnar , Jann Horn , Juergen Gross , "Liam R. Howlett" , Lorenzo Stoakes , Madhavan Srinivasan , Michael Ellerman , Michal Hocko , Mike Rapoport , Nicholas Piggin , Peter Zijlstra , Ryan Roberts , Suren Baghdasaryan , Thomas Gleixner , Vlastimil Babka , Will Deacon , Yeoreum Yun , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, sparclinux@vger.kernel.org, xen-devel@lists.xenproject.org Subject: Re: [PATCH v2 2/7] mm: introduce local state for lazy_mmu sections Message-ID: References: <20250908073931.4159362-1-kevin.brodsky@arm.com> <20250908073931.4159362-3-kevin.brodsky@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-TM-AS-GCONF: 00 X-Proofpoint-GUID: CdA-H8SVNxdbZ5nTnrwiW_1I0UR-iy8D X-Authority-Analysis: v=2.4 cv=Mp1S63ae c=1 sm=1 tr=0 ts=68bff61c cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=kj9zAlcOel0A:10 a=yJojWOMRYYMA:10 a=xmnICLmBNk8AszDsb_MA:9 a=CjuIK1q_8ugA:10 X-Proofpoint-ORIG-GUID: uTrJRk-Nt5us74ILiXCJ7SL_HOQZhnLx X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwOTA2MDAwMCBTYWx0ZWRfXy71df+5jjUw/ ntr+yICfUeQPRObSlyN3Yh1y4xhRnHGHhZFfRZCcvuRAacCykIbiLJkHQ30eUBJKOGl10TSIS42 +3nIeLTG23/y6JszEVZ1Ed+b1iNk9DDxZsvwkIfCXfzVoNJXgV1cawSe1+N/vBFlEkK7ENOmW+P 5QFev+/ePpqxVRniHssrBkwoaFfvkZZLW/2f9hVQyEtzMR8VsnBMkGYw6WFkufIgIXN5VkhAYVQ X+97jjddjBhYGKbSAHhaXMbOCL2qCKM7v5sv/V5bw5Wl8DJ9XDeAuCQ/41VgYzOkHMOtqD+ztQw 0x/7e9psYHEV7vlYlvzJw+aRJnWLrm5gVwmA8e51Z46BZm3hlJcuLkZtLVQrCNNUZn7EXpW7Hgp /9u+P9X3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1117,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-09-08_06,2025-09-08_02,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 clxscore=1011 phishscore=0 spamscore=0 adultscore=0 priorityscore=1501 bulkscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2507300000 definitions=main-2509060000 X-Rspamd-Queue-Id: F131840006 X-Rspamd-Server: rspam05 X-Stat-Signature: xee57yadkqbryzyh1mfp5y3kgq9rqwkj X-Rspam-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KBqkKDdckaG75ZF3lrt+21oeU9T7s+NwGxqRKxGYFMDYHyoNRA33Z83db6qNkpsAUmcusf8gfSkZaLEg0DMrhQeuI/gWA1FAUkwo9feJxRJ3MvMJ/puo2hsPVp3V5A2QmWUZTt+tu2PAOtdvLTCbws1maeLyZ8mtygWE7fxuecycJn2ng+8wjERPMWnJ9PIb/rCM9zF1R06/omEnA= 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 Tue, Sep 09, 2025 at 11:07:36AM +0200, David Hildenbrand wrote: > On 08.09.25 09:39, Kevin Brodsky wrote: > > arch_{enter,leave}_lazy_mmu_mode() currently have a stateless API > > (taking and returning no value). This is proving problematic in > > situations where leave() needs to restore some context back to its > > original state (before enter() was called). In particular, this > > makes it difficult to support the nesting of lazy_mmu sections - > > leave() does not know whether the matching enter() call occurred > > while lazy_mmu was already enabled, and whether to disable it or > > not. > > > > This patch gives all architectures the chance to store local state > > while inside a lazy_mmu section by making enter() return some value, > > storing it in a local variable, and having leave() take that value. > > That value is typed lazy_mmu_state_t - each architecture defining > > __HAVE_ARCH_ENTER_LAZY_MMU_MODE is free to define it as it sees fit. > > For now we define it as int everywhere, which is sufficient to > > support nesting. ... > > { > > + lazy_mmu_state_t lazy_mmu_state; > > ... > > - arch_enter_lazy_mmu_mode(); > > + lazy_mmu_state = arch_enter_lazy_mmu_mode(); > > ... > > - arch_leave_lazy_mmu_mode(); > > + arch_leave_lazy_mmu_mode(lazy_mmu_state); > > ... > > } > > > > * In a few cases (e.g. xen_flush_lazy_mmu()), a function knows that > > lazy_mmu is already enabled, and it temporarily disables it by > > calling leave() and then enter() again. Here we want to ensure > > that any operation between the leave() and enter() calls is > > completed immediately; for that reason we pass LAZY_MMU_DEFAULT to > > leave() to fully disable lazy_mmu. enter() will then re-enable it > > - this achieves the expected behaviour, whether nesting occurred > > before that function was called or not. > > > > Note: it is difficult to provide a default definition of > > lazy_mmu_state_t for architectures implementing lazy_mmu, because > > that definition would need to be available in > > arch/x86/include/asm/paravirt_types.h and adding a new generic > > #include there is very tricky due to the existing header soup. > > Yeah, I was wondering about exactly that. > > In particular because LAZY_MMU_DEFAULT etc resides somewehere compeltely > different. > > Which raises the question: is using a new type really of any benefit here? > > Can't we just use an "enum lazy_mmu_state" and call it a day? I could envision something completely different for this type on s390, e.g. a pointer to a per-cpu structure. So I would really ask to stick with the current approach. > -- > Cheers > > David / dhildenb Thanks!