Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2692522lqz; Wed, 3 Apr 2024 06:08:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXYFAW5ikdKr0C6z+dsKd5P/f6t5lDn/83s/Ds9XyjxahqwWmmR5ew7Oy/Q1iOvalqnmmCVu2XQ0ih7GwxTxdfediIJZext6Cn1JwQfzg== X-Google-Smtp-Source: AGHT+IH0wm7W88p40o1W45rcVzBeyt/O7hMbXlziqrrNjswiRQfEwRHmkYtVKmd82iJ+/RHjzYbt X-Received: by 2002:a17:903:32c8:b0:1e0:b628:a752 with SMTP id i8-20020a17090332c800b001e0b628a752mr3454210plr.7.1712149692631; Wed, 03 Apr 2024 06:08:12 -0700 (PDT) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id g3-20020a631103000000b005dbec3481efsi12975123pgl.91.2024.04.03.06.08.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 06:08:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-129783-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=EZsUjcmo; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-129783-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-129783-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 9682F284E86 for ; Wed, 3 Apr 2024 13:08:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A9A3F147C6A; Wed, 3 Apr 2024 13:08:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="EZsUjcmo" Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2127.outbound.protection.outlook.com [40.107.237.127]) (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 C760758112 for ; Wed, 3 Apr 2024 13:08:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.127 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712149686; cv=fail; b=Y+yV+1BgbRZ50dWf1HzDYQOnHa3rfYpBafyT/Ux6+HpmpZcONglAJBwzVJzWYkbJPNyAGz4QeyMYJmwYv7w9wWBCT8jW2PBlpjd2Ad78Xt5j0o9tAMZQqzjlfLu/bPk9U0GqRovqJpPlbCWuucXqLjuYYGCzvTGIINV/Mnd2M4c= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712149686; c=relaxed/simple; bh=MzGPXBvbU3OqD5pgX8xsXafMi4TEN6TTqeXDnXMqqxM=; h=Date:From:To:Cc:Subject:Message-ID:References:Content-Type: Content-Disposition:In-Reply-To:MIME-Version; b=UTiXQXhWiKbB4IF7eD8VjJ4Wl3MjMuCRjPupjswtodk+8eOXCotgTFJ63Z4dLzNyGc/mIoctgoegFEGZHVuxdmMHKN2n6m6AAgjk0lxYuqqbaftrvWoKQZKSv5/BCGtO9YESZal/1qmYz74W1qI8ArdlgxVWWVl5EZPB8pV+uA0= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=EZsUjcmo; arc=fail smtp.client-ip=40.107.237.127 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=N3w25fck0Xw5esq4kGkhlplhRtKt3Bhqc5wR4rOUIYDFeDszchdOTgHojSkhQ8Q8VNNgJHgzCYIeLCtfQT+PhnWk5CYcZNTnx/VdJ6K1/g66MfE0BiOuZ38MP8ojU8YXwz5QAmCTc5dStK/Awf/o1+DxQZPJhNMYkADcQCZ2CVzHY88dHt/86DJfbLKaVHSkcRH0irw+UFElzkc8VTelNReatVwY58LVHvrWoKwXpHr/qz/pZ6EyaYcWCNOgLS9uhLkVFqw230p3FQMjDm0UFdrWKKWQOD4CSt2I7yDJ+IbEvh3RfVRLqb57c69BPGKQtoRUKU8kBwqR+I1Kj4uO2A== 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=WPKLtrzmN9+lHp7by/pqxBXrsMwmMThT5Y3YwTuQlGM=; b=R+/ISom/+zs1gxF6ifk2YxJpRCzfWk/YuHH5rg/F6xx/3WyPn5X/jmLcpTJRNR7LyCyMZLySUFIczydeXfJ0G30L/qT0U6Ux2B9JJabXXhknXJ1DJKYeDFRbYm+nx/U1IZ+CjWSYBcTj5U/0Kaz2F7c9PDatG3uewSaZxQsXZ4Eu9ccwcIKLPRilgaoVhfvrWG5vkYN1l/0RwrKxrObbpXNS5yi872f2L2UHAa1BJ5FAY4F6mOvjpVy5B9N95ut4cD4fMLlAcmWnDh9IHzfJeRhQfLRsiTCdfRVMHMJIWdQ/Eu+klXh22wSZOnzPfIL69DVpuBdfIXNqlMc+XGMY0Q== 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=WPKLtrzmN9+lHp7by/pqxBXrsMwmMThT5Y3YwTuQlGM=; b=EZsUjcmokCmLxDCQkCwetwzq8kIyQ1YN146Rv726L2IOJHQcDnvuVi+KdVxZXRq7oMliaWDFDw/NqYeCycOM61p+9GMS/5Zmx+Nhk9+rZzxFa8nzibbTgsyXFcFN9mqSRyFJQghxmLSbRyr/mrFXDQiQFQO5A0433vqccwe/0Hbc7QtPncpgJ5Hl3Hx+in0ABxn4kLDXAy24WGnjYwRIKAr5f+cjjd9qUUOyXPVmIsEZ5mgPaOkDkngZyDOwFvLOn3/FgHZb3HJTabByubeSSkcbvk+F+SaL00fck/VhZcxUEGD7kszJO35GmeINHfkM766eM4yOPcwACCW4Pw2tPw== Received: from DM6PR12MB3849.namprd12.prod.outlook.com (2603:10b6:5:1c7::26) by PH7PR12MB7308.namprd12.prod.outlook.com (2603:10b6:510:20c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Wed, 3 Apr 2024 13:07:57 +0000 Received: from DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::6aec:dbca:a593:a222]) by DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::6aec:dbca:a593:a222%5]) with mapi id 15.20.7409.042; Wed, 3 Apr 2024 13:07:54 +0000 Date: Wed, 3 Apr 2024 10:07:52 -0300 From: Jason Gunthorpe To: Christophe Leroy Cc: Peter Xu , Nathan Chancellor , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Yang Shi , "Kirill A . Shutemov" , Mike Kravetz , John Hubbard , Michael Ellerman , Andrew Jones , Muchun Song , "linux-riscv@lists.infradead.org" , "linuxppc-dev@lists.ozlabs.org" , Andrew Morton , Christoph Hellwig , Lorenzo Stoakes , Matthew Wilcox , Rik van Riel , "linux-arm-kernel@lists.infradead.org" , Andrea Arcangeli , David Hildenbrand , "Aneesh Kumar K . V" , Vlastimil Babka , James Houghton , Mike Rapoport , Axel Rasmussen , Huacai Chen , WANG Xuerui , "loongarch@lists.linux.dev" Subject: Re: [PATCH v4 05/13] mm/arch: Provide pud_pfn() fallback Message-ID: <20240403130752.GC1723999@nvidia.com> References: <20240327152332.950956-1-peterx@redhat.com> <20240327152332.950956-6-peterx@redhat.com> <20240402190549.GA706730@dev-arch.thelio-3990X> <20240402225320.GU946323@nvidia.com> <20240403120841.GB1723999@nvidia.com> <3da59746-8acc-4a91-a19d-79a37ac75a8e@csgroup.eu> Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3da59746-8acc-4a91-a19d-79a37ac75a8e@csgroup.eu> X-ClientProxiedBy: SA9P221CA0007.NAMP221.PROD.OUTLOOK.COM (2603:10b6:806:25::12) To DM6PR12MB3849.namprd12.prod.outlook.com (2603:10b6:5:1c7::26) 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: DM6PR12MB3849:EE_|PH7PR12MB7308:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2FN5sV7ggEC4QGfJXPKiiBqIaTFE1ktvqeTVs4zje0Ra+fmuIRfTH6zQWioXqzsuz6tnnTL+kD31bhztM3zXi5FrMsLbY10BvsaG5f9tfym04f2xdYEQp0768gTs5ndUv7sfA6Li0A3QSXvXKZE1Y49GXHJ5gg1rg0ur+PH6KS0Nr+CEJ+DsYN+Xc8AEt54prP0DLph29QZ8k8ND/vz1K/LNoycgpbjlk2Nq1jHd8lLJ1SUmNK9xye4SjDwBgaB6VSMtCTW7WyQaZjBwE3ufET2Gf5XAmUvUbIVht42svTXlPKX5X8CZiTQZiXIvx4mtQiE5i1h9xgr2Fq5moPkvNkXeKxHbqwAzMnXLFilcvY/LniK/WJoyjhNCh2l1pOONIWV3s84yfkLrCnWX2jxI/a/AV7LKGvIDixUNs+M9cSWQNA+NRR8QruTSAY8Mo0lp5t8Tz/fH3cs/EGmUtXjfh8Prsd1Nd5utyDZgKue/AHyMpzvFnqsnQeDosFDcx+7PUZCQtdLishtf+OxjH/6FOawBgwJ5OT7f5jVCLxJKiDK4kNC+qzA7Jh8Vw66aokhv+o+8bS8RuaSV2N85pV8zHot+IeL9raPWLxKi9PiFalW54XdBS/XeSsmc8xO+5FbHML7GV3DspL5GaUeXh1gb6LhsiJH7FwFLBaGIkYqMik0= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB3849.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366007)(7416005)(1800799015)(376005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?MVB3NkR4ckdtWHhEcVRyZVA0RWpoWFIzTjZkOWZLSUREb1Mxck95Kzh6dVdT?= =?utf-8?B?WU42MWg0ZW92SHI5ZlR0MHVTOEJHSnNCMDJBcnBORHlTRDBSNE01bEVrQ2Z0?= =?utf-8?B?WlNhdk5TYXoyMU9WaUdVUExhQmJBbThxZTV2NjFITklSYjZBTktsQmU5VjFm?= =?utf-8?B?N0NtRVQvZ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EhBMVdj?= =?utf-8?B?cDIyc201dFFub3JXbFdVakd2VXJxM0FaZFpmMmdwSTNBVkVtZ21mRWdYTnAw?= =?utf-8?B?TEkyMFdnRjMwakVuN1ZHUndHYW82dWNEYVlBNEE1UWtIRVhnWVhHSFJqQ0FL?= =?utf-8?Q?WZmjXLZHjTKALExzitY+uTAbW?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: acc4e13c-4496-485c-17cf-08dc53df1337 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3849.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2024 13:07:54.6299 (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: H6oFKsgagNWFi9pA8yE6mLHKr7nCI/bWxa0QlCbovMHfTFY3OK5bntAFNu92bq5c X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7308 On Wed, Apr 03, 2024 at 12:26:43PM +0000, Christophe Leroy wrote: > > > Le 03/04/2024 à 14:08, Jason Gunthorpe a écrit : > > On Tue, Apr 02, 2024 at 07:35:45PM -0400, Peter Xu wrote: > >> On Tue, Apr 02, 2024 at 07:53:20PM -0300, Jason Gunthorpe wrote: > >>> On Tue, Apr 02, 2024 at 06:43:56PM -0400, Peter Xu wrote: > >>> > >>>> I actually tested this without hitting the issue (even though I didn't > >>>> mention it in the cover letter..). I re-kicked the build test, it turns > >>>> out my "make alldefconfig" on loongarch will generate a config with both > >>>> HUGETLB=n && THP=n, while arch/loongarch/configs/loongson3_defconfig has > >>>> THP=y (which I assume was the one above build used). I didn't further > >>>> check how "make alldefconfig" generated the config; a bit surprising that > >>>> it didn't fetch from there. > >>> > >>> I suspect it is weird compiler variations.. Maybe something is not > >>> being inlined. > >>> > >>>> (and it also surprises me that this BUILD_BUG can trigger.. I used to try > >>>> triggering it elsewhere but failed..) > >>> > >>> As the pud_leaf() == FALSE should result in the BUILD_BUG never being > >>> called and the optimizer removing it. > >> > >> Good point, for some reason loongarch defined pud_leaf() without defining > >> pud_pfn(), which does look strange. > >> > >> #define pud_leaf(pud) ((pud_val(pud) & _PAGE_HUGE) != 0) > >> > >> But I noticed at least MIPS also does it.. Logically I think one arch > >> should define either none of both. > > > > Wow, this is definately an arch issue. You can't define pud_leaf() and > > not have a pud_pfn(). It makes no sense at all.. > > > > I'd say the BUILD_BUG has done it's job and found an issue, fix it by > > not defining pud_leaf? I don't see any calls to pud_leaf in loongarch > > at least > > As far as I can see it was added by commit 303be4b33562 ("LoongArch: mm: > Add p?d_leaf() definitions"). That commit makes it sounds like the arch supports huge PUD's through the hugepte mechanism - it says a LTP test failed so something populated a huge PUD at least?? So maybe this? #define pud_pfn pte_pfn > Not sure it was added for a good reason, and I'm not sure what was added > is correct because arch/loongarch/include/asm/pgtable-bits.h has: > > #define _PAGE_HUGE_SHIFT 6 /* HUGE is a PMD bit */ > > So I'm not sure it is correct to use that bit for PUD, is it ? Could be, lots of arches repeat the bit layouts in each radix level.. It is essentially why the hugepte trick of pretending every level is a pte works. Jason