Received: by 2002:a05:7412:8d09:b0:fa:4c10:6cad with SMTP id bj9csp28707rdb; Mon, 15 Jan 2024 10:51:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IEMqVfFOlLIsFqcz2Bl2vmIOZP0VRpu63vCLnj21dWTqpv14vtWe+fIK4j7EYo/1GAbkalh X-Received: by 2002:a17:903:278c:b0:1d3:479d:3d56 with SMTP id jw12-20020a170903278c00b001d3479d3d56mr6209504plb.133.1705344668608; Mon, 15 Jan 2024 10:51:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705344668; cv=pass; d=google.com; s=arc-20160816; b=xWClCem1sZnH+F9Rx2ttohmJA3lE2AN+je33FBe/0kAifAonBz1icOcwiHzfIufH2M DPUWWsjl0bDvkA+VTeSW/PHlexY74KzXzMHiCd5Wr2YNuItTwqpHqIqqJv682oVBjB7z 8y4IKTN3tISrTRNaRaqavEGxVaOiCGIc0WvwSxaap/ekiizfNQcWn8Qvtl/1SKYwD9aO Al9MSyh3kzcNhLuKvu6HeXg10bQNYIx72BMYgNtaTqr375LBpElIltI2lBRml6z4jN7N +JMzE6nnEOx7OD6R95e4Vf+DsNtts2VxIqRTlh/lI+HLm96ukEy+ieorUS82ll+0zGL1 YV6w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :in-reply-to:content-disposition:references:message-id:subject:cc:to :from:date:dkim-signature; bh=P5ILbPEFZmyJGFxhbK2YHEHlIEDwEAx0Z+7w9UPEIss=; fh=WF0vKtkhjpNFiqWiksO5OqVIH4oI4WQuuw40pJ3Csu4=; b=SPkhKWkCsSqvrgetOzwzTdxfaALgtNfbG4JLF32qMP/O697Q8S2e6FYsT9W3Xi10ew Y1E30utt20KvUjGzDpVQ4HbWoIaTqMCDK7j5blNm7YHvR4iIef32Iq1//76N8zWkljFB Il9vYRjLVtjL14Ohu/cV23+KP7RNuqdJ+5HGKBGm/9sRTsEud6cimFt/bFQ/XJvr61vx E3ZR2hlIFb6BzLpA9tefqoO/DtppHMkgHN78hjV+VxH8WKh5Q/0sCNBhshonRxql2e4S 5LPzsuEbYh/D/X9r2fQy94fpttR76OqeuWbR+zqy6oughcY20HqjRWzpk1HF10ghLmU0 TV0w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=CIHuKl2o; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel+bounces-26405-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26405-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id c6-20020a170902d48600b001cffca283fasi9987815plg.144.2024.01.15.10.51.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 10:51:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26405-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=CIHuKl2o; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel+bounces-26405-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26405-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 91E3728446F for ; Mon, 15 Jan 2024 18:41:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 40E5E18659; Mon, 15 Jan 2024 18:41:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="CIHuKl2o" Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2086.outbound.protection.outlook.com [40.107.244.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CCDA018636 for ; Mon, 15 Jan 2024 18:41:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kfOnkHUJ96vV5TWvE6cBV2CJMc7WvviwU5dX10rHr2G3/YdyxO882HcUsoSlI3+us7OOVQRvHoTJNnDJiHc3kv+tSgHXoFuZEhAgAVEb116+c1hnUjHNOleGL4itfa05QTw9KL14dWA1kNp3Yb5aQ0IOVpwbyxr7yKfVmKF6/WKgdAsvfrOhH/1/awE8tEqC0Ojh5wlGDfw+/A1kOlEE3QtixcLuS4wwrHGtM+SDLVE7kNnpi4xFc79ZUoULqlXqjNxLPNowlEHXn+gIAcVHNElyq4g4nmXlzQZXANZOJT/gyZthmUoFMIo0nLKMhE6zTS9IOPlJDs1f5GWXQKuqjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=P5ILbPEFZmyJGFxhbK2YHEHlIEDwEAx0Z+7w9UPEIss=; b=my5bzQsQ3MlzO20FMwm106lmbNiTfMnTOkg/kbF22GaN5w4HeW32ZRiEVkGn5z3FyNqjyaHg3aB+3VrJxe0YE6qGdPxRfliJmDXke+6eDxNAibqMU926L7jSUZqdupB3W3M0BQwLmC9in8YQjlCtSSgTTucjnQG5L4AybfCQ8P6rmBTP5FdHebP+7gpm4cstffSj5A/jkajy2akD1hiV1xDsHIug9JTSfrUgcHs6xNhH9eDD8xl2DfIiigJzKG/5lAAduMIypX7KsBw6h1SPz0zfJVYDJsUOew/v2CJ3N0hpUYeKHdKJJY3vK/lIZv/Y/kZS/Uaum066wEedO3IoEw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=P5ILbPEFZmyJGFxhbK2YHEHlIEDwEAx0Z+7w9UPEIss=; b=CIHuKl2oPBjTrK1o8pQWgYRBNEbNcx38F8/1uYku2zhtnoQ6Pa8M2kq0Z980pYbsaoA7tkv3utPgt8Gl021TvPLqlUT++OBQfoO3HkPPozjpk0qo9yvCcd5K4ic+em8XCPy8q4A78XERVW6xBgeMRfJnochW/ROWUGDVWXwx5SK56D3BycRQBhDp/kcl1sZ+W+JqW4RJ6fCPsheOW/dSKb8LF3s7s0mM30Orep3JTKUr4ifrR8muF+6QfeHHL293BNhFuB+7wjmDN9DJVvGSf47v0M60uVd/f3kxBzL7oIzMkh6Yu29ZYGhmVFMve0jjurRTrnVRgqV2t0BfVQmR4Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by PH0PR12MB7792.namprd12.prod.outlook.com (2603:10b6:510:281::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.23; Mon, 15 Jan 2024 18:41:03 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::96dd:1160:6472:9873]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::96dd:1160:6472:9873%6]) with mapi id 15.20.7181.020; Mon, 15 Jan 2024 18:41:03 +0000 Date: Mon, 15 Jan 2024 14:41:02 -0400 From: Jason Gunthorpe To: peterx@redhat.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, James Houghton , David Hildenbrand , "Kirill A . Shutemov" , Yang Shi , linux-riscv@lists.infradead.org, Andrew Morton , "Aneesh Kumar K . V" , Rik van Riel , Andrea Arcangeli , Axel Rasmussen , Mike Rapoport , John Hubbard , Vlastimil Babka , Michael Ellerman , Christophe Leroy , Andrew Jones , linuxppc-dev@lists.ozlabs.org, Mike Kravetz , Muchun Song , linux-arm-kernel@lists.infradead.org, Christoph Hellwig , Lorenzo Stoakes , Matthew Wilcox Subject: Re: [PATCH v2 09/13] mm/gup: Cache *pudp in follow_pud_mask() Message-ID: <20240115184102.GU734935@nvidia.com> References: <20240103091423.400294-1-peterx@redhat.com> <20240103091423.400294-10-peterx@redhat.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240103091423.400294-10-peterx@redhat.com> X-ClientProxiedBy: MN2PR10CA0009.namprd10.prod.outlook.com (2603:10b6:208:120::22) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|PH0PR12MB7792:EE_ X-MS-Office365-Filtering-Correlation-Id: abc36491-8ea8-4287-4ecf-08dc15f986b8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qEZbr8p5qAVsT4X0pYjH44zb2n/4om7g3YXgAwzlK+pKJ+GHnfS7/qvnMughiGTHsoY/k93RoJwA3/2j6peUfUzDUqImrQzjYzne8KxhOjzO0mjAcOfSrkegsbObx2RPgSC0F/bm9i6z3Rxb9wQt0bT54nRfC3HxVlOHxCns0MFiW6omZ6Q/ObOcmvS0Wb12d73j38fYw7p246a+OMqyE+Fj3JNT60egl2ehVtqwjiBS6Z7PrmIhNM2gFmvYjIDt6W3NPeNhh4UVgKc4sXCXVTqfw2ScPUkSlvTIeymdsFHKqv/RYbT2e2okhfkrxjR7CZCDFPb/85eW1EPF3JqeYiXMQm6hlmi3VRFXkKAQJvPNaU4x1s0uRE8aJXa+3gFU9e5APU8Z9P1aqhSXb58ecLMy0io27rmmU/rFjq1mAmYiGvqBLyAcYajtlqyTFxJkos0qvdkIOmaVGpdd0kxatw/eLZ0Dp+Qex8U95BbCmix4YkSLqb4ALRgIvZVEit3KUzJu9Nn7Y4ILln0iroCeC+0g6znTTbwJr8sO2c5JFeqUDHvsnjNpXQnDRVIolSdiCbL7+mcy2fe4ttDPlim058KuJtJ7O1U0Y1B9y2j+Kjw= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(366004)(346002)(136003)(376002)(396003)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(66946007)(83380400001)(6506007)(66556008)(6512007)(26005)(478600001)(1076003)(38100700002)(4326008)(2616005)(5660300002)(8936002)(7416002)(4744005)(6916009)(54906003)(8676002)(66476007)(6486002)(2906002)(316002)(33656002)(36756003)(86362001)(41300700001)(27376004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?C6Q4bQcf9PvJCs5KvaZDIXKIi+dVQ0rNEfElxA/30WhejkyzRDyadFx0Nx9i?= =?us-ascii?Q?wNIY/PWj+4R24SE0/kjIkuIJpc6gIKNaEzA9w1gH9/8RB/YwlGMgH6vCJopJ?= =?us-ascii?Q?9zf8Z1tzjS58N5TqaBdtUzxvsJhAnBASsuUqnfi3QC2pDJECYo4GB77loCyI?= =?us-ascii?Q?3xyg9Au7G0A+TRaZ1p7ZQgkhQWGuGu0yQLv5nIxmygKBja3a0EkhP/W/8FcM?= =?us-ascii?Q?9hyaCgjQXa4Uj9DO8jT5ky7SnNHibF1xZCdVIsVDns9LK9xHGNRCky0KRgRI?= =?us-ascii?Q?O8jbnN7DtZTbJUbIyJ973i7zWTMGSsjMikf2PHjpvX4fS+z8GepaCT7UNevc?= =?us-ascii?Q?HKTdCF+dHk8d6+7AsMJ5DKMT9bUmEr2pynUj58t/2yiLz+DgMEBLSQskrfXD?= =?us-ascii?Q?VxfQUD7vdhz9hxku3HeS6FxAt3FGjCEfEQMzWd098e443PuSKpogXbSEkoeS?= =?us-ascii?Q?e+xRyzd/Wn1Ef7RgDnVr3UcxB3vQ/MLbGJWHHuBKBA2ZJW4xIasWxqQB8323?= =?us-ascii?Q?cUxvTdGayBGUivQ8pXpB7x7rbONcH/mUSYTQPhMFLvuVsxe+qpu0dNDA4NOa?= =?us-ascii?Q?w9Xm39Pj5ad7eVZBl+cAXuUKu+lGanAYsqjLM5oEeeUiiSQWu1uLOvk8R8Oj?= =?us-ascii?Q?9Ji6MBeDh7MrlzN/bFCBd5p86nGoFvaCcSivyN1vyAW9F9O1xnZTodFCEFJo?= =?us-ascii?Q?V8+zIk76lYWrPChN8n8/KRe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-MS-Exchange-CrossTenant-Network-Message-Id: abc36491-8ea8-4287-4ecf-08dc15f986b8 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jan 2024 18:41:03.2308 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: i3uKmk1oZbZ8NDMj2a4Z/x072dEUACMzUR1yIEo3ddZUPH1dFQfBO5puws2dAukf X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7792 On Wed, Jan 03, 2024 at 05:14:19PM +0800, peterx@redhat.com wrote: > From: Peter Xu > > Introduce "pud_t pud" in the function, so the code won't dereference *pudp > multiple time. Not only because that looks less straightforward, but also > because if the dereference really happened, it's not clear whether there > can be race to see different *pudp values if it's being modified at the > same time. > > Acked-by: James Houghton > Signed-off-by: Peter Xu > --- > mm/gup.c | 17 +++++++++-------- > 1 file changed, 9 insertions(+), 8 deletions(-) I think we have several more case like this, and I ceratinly agree code should not access a READ_ONCE variable more than once :( Reviewed-by: Jason Gunthorpe Jason