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 D4809C0219D for ; Thu, 13 Feb 2025 09:17:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 677626B0083; Thu, 13 Feb 2025 04:17:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 626ED6B0085; Thu, 13 Feb 2025 04:17:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4EED46B0088; Thu, 13 Feb 2025 04:17:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 322A56B0083 for ; Thu, 13 Feb 2025 04:17:29 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C5F941C7EF3 for ; Thu, 13 Feb 2025 09:17:28 +0000 (UTC) X-FDA: 83114368176.12.2FFDA03 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf15.hostedemail.com (Postfix) with ESMTP id E406CA0016 for ; Thu, 13 Feb 2025 09:17:26 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1739438247; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7lIBEm48K7kx+TQb2o7cJxdcD+TD2KdtNI8Np109gcQ=; b=GGpmLz/hBGtEYeOoKCdhWU+gR1zJckR0ByLIDTTDyiNUUy7dcncJ5vutpjF9+dvnl7VuJ0 zYsDC09/bhbkJHB5qJUcjHDYjWIGsmm7LTYs4dX6kQPlJDEt+Cunbjpy5TPGPtQK27ZUmg qnPdC32wy4oVn+5oLpDF3/sMIYtr7JQ= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1739438247; a=rsa-sha256; cv=none; b=JUprbeKJgbdkH8ukYRgRd1+lUd7YJRlrwV0kpiBPWLGT9oV3e/eaZZ1J7Cp/fOgUMLAEBD aEJ1TzpXhbpoPAguQRTOeP8mxU43uBtvHm7EHjX+6YDGEnv6D/RFkkCJ46I3uJhteTPfMt OaT5uEpIug3bYqsvvMJRfOswNufFQjA= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D1F4C16F3; Thu, 13 Feb 2025 01:17:46 -0800 (PST) Received: from [10.57.81.93] (unknown [10.57.81.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8C1C53F58B; Thu, 13 Feb 2025 01:17:23 -0800 (PST) Message-ID: <67bcb2f2-8cc1-43e3-b5cc-6c8ef5da8a95@arm.com> Date: Thu, 13 Feb 2025 09:17:21 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 15/16] mm: Generalize arch_sync_kernel_mappings() Content-Language: en-GB To: Anshuman Khandual , Catalin Marinas , Will Deacon , Muchun Song , Pasha Tatashin , Andrew Morton , Uladzislau Rezki , Christoph Hellwig , Mark Rutland , Ard Biesheuvel , Dev Jain , Alexandre Ghiti , Steve Capper , Kevin Brodsky Cc: linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20250205151003.88959-1-ryan.roberts@arm.com> <20250205151003.88959-16-ryan.roberts@arm.com> <43c256b6-7e44-41bb-b0c5-866fd4faab5c@arm.com> From: Ryan Roberts In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: E406CA0016 X-Stat-Signature: 49nypa5p5cjqx91ppzif6sh4od46xgpg X-HE-Tag: 1739438246-744390 X-HE-Meta: U2FsdGVkX1+1ouLBiDSOmPmlaT3CWd71urk22ix2hOhmzz9pIPhs2QUVE/RhldQTQv0SKnoi8Tx1nyF/EL+KZc7StpUO/rmFCQJZ2gFdgHRQv/JKNxmJNG4CxEa6t5cRtG2QHQ65IauNJO+UnJTzEJnIetTi2/tLoCHvcUzaJjy2rbKlyhzXMCS1FcX6m4D2lEhGDB3lstgqhm0p7kmaG5CXxqy+1tyPXOjF8/LmY3wE5LiqNitvz3NQm949QlB3JThxLUfDY3w+fIcRM+a1U4Z+CUf7uaYrpJP0ABUC873JvTUs0A2s2rOT0wK2BSXbCNyjJBfJwaQf4Uo+LauABi6E13ifviYcm09pwqBQIS5FNpUoCaXXDUVPBRHM7rEBwDrgDL3eonkXRIMrxGNmEqwbVG7Ov3TplyDGiQTclH+8thg8z4DokTqyg9h5m3DlLQ8uy0YGaUcXSyF5mPcgUcjTEPCYslmvwlVuoVLzaiEV+TA4I5h5NLvk1xoRm8DzIxntWYOVz347DMrUKriKLWD2Y92C6IJnWYCkPdkxeSRbiohjzhcllozPxLkAxHt15UbU2RFJbgCHcuxzPRvIdZr4D+Spa3PoqQtpV0BJkqr1s1b6gvBivBYQHzJWPoVCYv0wl1iLRdD6fzlafG20mfoaJGx1nA6/j5TESiuMQYVHYcwWjyGq1Ok+uRMuUNv2h+iCZEcel7Trya9Lg5m33y3TMFKmMHfTIswedJLN3MtwdKgsT5wwrQhzhKLXnOj314pSR8wDkC+W0foaXCF5MJDwdaZ80834J9enZpb2GvAyC6udgdLOKYAK/k7ebiHV7xB2q6Ih3QQfkZzf8+ue19Z3Mvl4xsUqso4iFluubUOMai9m5Su1IaMWZHiMr7Ku8DP29cffdg/6lIGqPaRfN1GUwaytIVIlHuPrbywWU2V4TEwQ5ynjkt4xwVBGst7BR0ZvujbB/XmiHBEUHSS GauhCTZM ZpPOCqRk9b2CuOpm0FGHNl6FpJY1IZ2ozYPHV2CAaLg5EgTeuDqM0JYINBE2tYistO2Z753RCB5kERNfZZ+BQhT5UcfF2Dhvl1wGdnlUPRvEtAEjXmQMNxbZ6N2+Fp4WfnxMMnNBJOGwwwABC3WgTTwJvBHa9j+BCYYEihkiIBfbhiVc7D6Sgbdl9GBOh0+BfnCQH 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: >>>> +/** >>>> + * arch_update_kernel_mappings_end - A batch of kernel pgtable mappings have >>>> + * been updated. >>>> + * @start: Virtual address of start of range that was updated. >>>> + * @end: Virtual address of end of range that was updated. >>>> + * >>>> + * An optional hook to inform architecture code that a batch update is complete. >>>> + * This balances a previous call to arch_update_kernel_mappings_begin(). >>>> + * >>>> + * An architecture may override this for any purpose, such as exiting a lazy >>>> + * mode previously entered with arch_update_kernel_mappings_begin() or syncing >>>> + * kernel mappings to a secondary pgtable. The default implementation calls an >>>> + * arch-provided arch_sync_kernel_mappings() if any arch-defined pgtable level >>>> + * was updated. >>>> + * >>>> + * Context: Called in task context and may be preemptible. >>>> + */ >>>> +static inline void arch_update_kernel_mappings_end(unsigned long start, >>>> + unsigned long end, >>>> + pgtbl_mod_mask mask) >>>> +{ >>>> + if (mask & ARCH_PAGE_TABLE_SYNC_MASK) >>>> + arch_sync_kernel_mappings(start, end); >>>> +} >>> >>> One arch call back calling yet another arch call back sounds bit odd. >> >> It's no different from the default implementation of arch_make_huge_pte() >> calling pte_mkhuge() is it? > > Agreed. arch_make_huge_pte() ---> pte_mkhuge() where either helpers can be > customized in the platform is another such example but unless necessary we > should probably avoid following that. Anyways it's not a big deal I guess. > >> >>> Also >>> should not ARCH_PAGE_TABLE_SYNC_MASK be checked both for __begin and __end >>> callbacks in case a platform subscribes into this framework. >> >> I'm not sure how that would work? The mask is accumulated during the pgtable >> walk. So we don't have a mask until we get to the end. > > A non-zero ARCH_PAGE_TABLE_SYNC_MASK indicates that a platform is subscribing > to this mechanism. So could ARCH_PAGE_TABLE_SYNC_MASK != 0 be used instead ? There are now 2 levels of mechanism: Either: arch defines ARCH_PAGE_TABLE_SYNC_MASK to be non-zero and provides arch_sync_kernel_mappings(). This is unchanged from how it was before. Or: arch defines it's own version of one or both of arch_update_kernel_mappings_begin() and arch_update_kernel_mappings_end(). So a non-zero ARCH_PAGE_TABLE_SYNC_MASK indicates that a platform is subscribing to the *first* mechanism. It has nothing to do with the second mechanism. If the platform defines arch_update_kernel_mappings_begin() it wants it to be called. If it doesn't define it, then it doesn't get called. Thanks, Ryan