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 4C75FECE582 for ; Tue, 10 Sep 2024 17:20:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D67A08D0099; Tue, 10 Sep 2024 13:20:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CEF418D0056; Tue, 10 Sep 2024 13:20:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B8FBB8D0099; Tue, 10 Sep 2024 13:20:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 969878D0056 for ; Tue, 10 Sep 2024 13:20:47 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id ED2D8140848 for ; Tue, 10 Sep 2024 17:20:46 +0000 (UTC) X-FDA: 82549493292.29.1560E46 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf22.hostedemail.com (Postfix) with ESMTP id 838A3C0003 for ; Tue, 10 Sep 2024 17:20:42 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="i9InMk0/"; dmarc=none; spf=none (imf22.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=1725988760; a=rsa-sha256; cv=none; b=lD9PvC6HrKCs7dXebIEV2NhzdS6pRYkNrSrTHghpN/nDIqGZJSpPPGB9c1zYrm0+e/ElnX l2EtuPLUjgPEfxcEpeF0zz+2jZl9X4z4on4k4wD32QqX5Inj1ytzRwd2X89hU6fRqpQSj5 1QrfGruesEwyoiI608akrZtVsrWqPb8= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="i9InMk0/"; dmarc=none; spf=none (imf22.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=1725988760; 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=OjKqo8IT8Dm4G10bvKkMI+1QL7t06KGHpM+aIqqBOtI=; b=8qolAdKK91059pIdI1rdgipMfLFjwLWuZbKyMZ6HY9nbWGAhRXZr606VJlHkJOHfphxdtz O+QOWr+iDeDNydQ3FwF83QCgPwqD3LJspWmtAj5S/ca0jmgrygUoRDSTXctOIO7fO/Kt/2 FX9Gc2wdedhsrX1PP8wcz6f45UlpFMY= 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=OjKqo8IT8Dm4G10bvKkMI+1QL7t06KGHpM+aIqqBOtI=; b=i9InMk0/8QoG2hGeu9bjCkGgot K71BplXZ6thqiZtpju1UR6soh7R+uybndCA+nr8tz1DjJGdMY9d07CQTHy9A9nxBNyEzGzb6EAr3T uUlaV25ZoPNOowoROO7WXS6+G/Y4TyKV1vD1qaJ0GFO3kj8gNKE8y0x5CjweQTz852lm6L/Qbil1r vSUYds2EF1Xgug2gwg+6D38LOTJtILqumaXoDS1U2gmx8YOHjgOnoIqRmuQZeXT1NxBmolmHiNwf6 bYvaDuovStcN5zymNoqBSFyNQFqlaaDCDBBD4h+M43zGDK66dpqYNqoxEnNtd2lRTpzFpDqG0i8Ie 4mlgzmaQ==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1so4Xf-0000000DE92-1IdE; Tue, 10 Sep 2024 17:20:39 +0000 Date: Tue, 10 Sep 2024 18:20:39 +0100 From: Matthew Wilcox To: Ryan Roberts Cc: Anshuman Khandual , linux-mm@kvack.org, Andrew Morton , David Hildenbrand , "Mike Rapoport (IBM)" , linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: Drop unused set_pte_safe() Message-ID: References: <20240910090409.374424-1-anshuman.khandual@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 838A3C0003 X-Stat-Signature: x3ujgjscyyqrrwy7zzrz3cspdmi5jxbu X-Rspam-User: X-HE-Tag: 1725988842-610873 X-HE-Meta: U2FsdGVkX1+UaqFP0r/bxDzmqmGcHBTMwopAfE3EySZC/5f7H1Svd/ztbXdoaeIonrg+VbAVPA+ETdDf5HgG1xxc1hEi4+B5xKT0EDeWGH3b6dvyPZ8EIp+enlGe4ZmnUXulcWP53SWgAtJHLpDn0erMYYRO+FjQPPugEJO7uL6wqsrj3fyRGFoYLWMJt8+Gs7sRi/hqmx2ovXpFWcWBHCwGPv0Sp9LHaL6yXqudjzcJQeuS6L8CQhnbbXlte52JSSkH6cKAG4gi2SLoq7zFmObjJreCEgyoZTvDQaAm35sEA0+9wvXy0p3pAeB6Iu4pGYP4VrRcHrh0+Z7ArcreHfLrxb/F70JZiryD2RFnL6hHxFJqjr/7N6gBUpDRLtqytNRJw0l3RJRh/pIVe4bNQsHHniF+EQekpfJv4ivAUQMCs4rQ4eP4Z17dP2fA7P1Yq5Q+UHaP4Ch5VYwiBAHdBf/aua9sfTq0d2fcgfZplXmiKcf+q+EiifhPCu9luBlloOdsHUVXIoUxhnMGXFpcmLT9ir7BkTMn7IiZQ4e6XxbyPZWA12/wX1SFGjahCv8ClJunfEOi/flzgL/OeVsOjDK/QPt3o8nrDGR8Qz0jgcJinDL6w1jRQ6fUMT6s0R65Tcqh2utKtK2RCQ5pCrspbK7Mep/k6D6DPB1Y2nPVSgNx345YbBWq3fKTOISVo7RY2TyXaYpqqbGvhNkWD4I8DKJFJu4QctwDB+cns31N/GtHWJfMm+9xZqglA1Jssw9ZjjBTj0M2dIzHoNQFsJe5QtZm1HtobQIvsQQfOw8cQ9aD/TDgORrKEaSgoBfBzEP0rwLH5yhxd12TZkxEiGspuRHLSs+7Cuuc10OrAt1HJiymdSCq4RvZdcsaMZuY14njfGD9FfjlA0P7G/9Va2183EdFlqFmDinQ9s2PAsVhuy95LGuRhxxeIJXUAW5zjudK+QC9KoCihzeAo8gqkW8 DfbInyn9 Dm0bTh/52kCj1X2Q1pVdA5s8N+tWkJWqHpVilGTtNe5E/gn1KGRc0kykimB8XIzCzLXzaDBk/bauLqDiec3LCRbhFLbquVj3lLefzgQUsHd4g+o8bq9VQmHneMY3W3pFr1Cp28nkHSyIFFz63MnNId0B7T4SwmEw1BpPx7FzWzghyiFXnSpkaJc97GXpOtxSMMWlshjQVRcLIDOT4QWMIb382mfschSyRKxSSZYvgWm6+bwGIWMYq2OAnte8CLkwgsOxVn5LNvPZ5uhEsdlIkQuzHsIzTg9ZKJfUg2tzXG/JdBwnqLWuXEcQH8BUSJR6RXtXbnImrPeE0w23lcfs4lBoGOO7FBDVxR4WyyNloWzC5tG9t4GykuufbFRWwuVF2QgkPkW75hqqndlZhlNW4MVEhgYrCSHYLXIiE5ss/wSiUOgMbz4pZmNY2BfagfnIGymjCxoKQLsKftUVu14J0btB38aYEZ3VO4CTKnPJ6HBamtvcEqYN2Rbez0Q== 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 10, 2024 at 10:08:10AM +0100, Ryan Roberts wrote: > On 10/09/2024 10:04, Anshuman Khandual wrote: > > All set_pte_safe() usage have been dropped after the commit eccd906484d1 > > ("x86/mm: Do not use set_{pud, pmd}_safe() when splitting a large page") > > This just drops now unused helper set_pte_safe(). > > It would be good to add some comment here to mention that the macro was buggy > due to doing direct dereferencing of the pte, and that if it were to be kept, it > should have been updated to use a single call to ptep_get(). I'm not sure that the _macro_ would have been buggy in such a scenario. If I understand correctly, the _caller_ would have been buggy: /* * Use set_p*_safe(), and elide TLB flushing, when confident that *no* * TLB flush will be required as a result of the "set". For example, use * in scenarios where it is known ahead of time that the routine is * setting non-present entries, or re-setting an existing entry to the * same value. Otherwise, use the typical "set" helpers and flush the * TLB. */ so if *ptep changes between the two calls, that's the caller's bug, right? Otherwise, set_pmd_safe() would be buggy ... > With that: > > Reviewed-by: Ryan Roberts > > Thanks, > Ryan > > > > > Cc: Andrew Morton > > Cc: David Hildenbrand > > Cc: Ryan Roberts > > Cc: "Mike Rapoport (IBM)" > > Cc: linux-mm@kvack.org > > Cc: linux-kernel@vger.kernel.org > > Signed-off-by: Anshuman Khandual > > --- > > include/linux/pgtable.h | 6 ------ > > 1 file changed, 6 deletions(-) > > > > diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h > > index 2a6a3cccfc36..aeabbf0db7c8 100644 > > --- a/include/linux/pgtable.h > > +++ b/include/linux/pgtable.h > > @@ -1058,12 +1058,6 @@ static inline int pgd_same(pgd_t pgd_a, pgd_t pgd_b) > > * same value. Otherwise, use the typical "set" helpers and flush the > > * TLB. > > */ > > -#define set_pte_safe(ptep, pte) \ > > -({ \ > > - WARN_ON_ONCE(pte_present(*ptep) && !pte_same(*ptep, pte)); \ > > - set_pte(ptep, pte); \ > > -}) > > - > > #define set_pmd_safe(pmdp, pmd) \ > > ({ \ > > WARN_ON_ONCE(pmd_present(*pmdp) && !pmd_same(*pmdp, pmd)); \ > >