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 83CD6C3DA64 for ; Thu, 1 Aug 2024 16:07:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 20A366B0096; Thu, 1 Aug 2024 12:07:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1BA556B0098; Thu, 1 Aug 2024 12:07:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 081FE6B0099; Thu, 1 Aug 2024 12:07:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id DA4986B0096 for ; Thu, 1 Aug 2024 12:07:17 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6F74480F5E for ; Thu, 1 Aug 2024 16:07:17 +0000 (UTC) X-FDA: 82404156114.12.5018792 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf04.hostedemail.com (Postfix) with ESMTP id 28C004001E for ; Thu, 1 Aug 2024 16:07:15 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Hix8EcbL; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf04.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722528430; a=rsa-sha256; cv=none; b=36BKyB4imLGtvup4H1NRYtSMaDlKSWaRgAeDZkqQRjkRIxLY3lg9r9dSNLkcg/x3HQHQTr 3tiUWjN6IaWb5pgjWsmgLhUaQzbUX/Z+s9+H7ERBzXkGYcc0dnbadYxv0L8aFsPMLqzqV+ XcNlFF49rh33xl0p4HNsvWewCaqvfBc= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Hix8EcbL; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf04.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722528430; 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=0jfgAWh3KxxRWgzDt61596NApFPizVzq8q6tnOLG4Lk=; b=c3DjUiOh8LIpaM8mYQpyyLxunshBFHUhiT24l+L9Tj0MO1ZnBdCtwajhLvLafMRoldeDM8 6/5k5PXWLoPiIAv2X8gr8Jh848M9xKmfDDQSRWMNnZMO1O35PlFfbZV/cFh//gDd/4rntH 6zW+WnEEJslGGfuvNYAIxGB7J9vfSnQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722528434; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0jfgAWh3KxxRWgzDt61596NApFPizVzq8q6tnOLG4Lk=; b=Hix8EcbLzUX3dTY6dMnW13mmDWLscmFHZRMPVT9sYBwYg7BmBDRoKcTubKVlH7NFtXJlGQ MvZrwifMehuiuIPH1nv9/3PZpMHtS89EmnzoVoDd61Lr20hQgqiMayEnO9NwCg0KJ7/+Ej wfTEgQzwoWcvCcfrDXX5cIv6c/8s5WM= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-383-IhhlM65LMS-KBZsgylvV8g-1; Thu, 01 Aug 2024 12:07:13 -0400 X-MC-Unique: IhhlM65LMS-KBZsgylvV8g-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-7a1d3392009so47803385a.3 for ; Thu, 01 Aug 2024 09:07:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722528432; x=1723133232; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=0jfgAWh3KxxRWgzDt61596NApFPizVzq8q6tnOLG4Lk=; b=vYqxBBDekdcyEFTzp+bWWbFu1xjeSYtvD6/pG/6xm0c4BkPmkbvH6U7F+3JlLgKbUV iR3agaakxtw0XTNyIutACegJ5pzfHAuUFTzy5b2USto5APEiEdEdhc03f4eEi1yBUWf7 KKQ780qxXga55Q0EWtxkrZYhyee7twXaH0f+B+H/jnMaYoyUK6ffaVrfNoMaP8Mmh5m2 gmvRudx0FEw72JD4QEU3WoEa2aq0LLTiuvzMX7fZ38Iqr46WZkWlslPVO8bvKo65yRl3 ak3EI9FkvSLVCDu+GsZvctAaVJcIGkqI+oR5I18/JrmmEkeTf61PntowFT0cGftJin8M cfCw== X-Forwarded-Encrypted: i=1; AJvYcCVH7W6aOk+dZTaLSxjhkt0NcogL8/iNPS9QTB+lM9LBxROCDkdvMrnzmfoKUq88bTI++0vaKvRovA==@kvack.org X-Gm-Message-State: AOJu0YzfR2FzpmNPMvg/JtBgNDh6Q3mwyTX5JRPzXZbzEa+X0p81mcKq 5ysOqAEY/a3/C6N24TV3F8yCiYIB0cW4cHC5QZ5MJ9cLOoH6EXwYbjOIyhGD3tPodr83e5/SYeH LURuiwuRR9POtfPZM7Fmauqkw+/FnB0o/YV5UQdjkwHlGiNOw X-Received: by 2002:a05:620a:28d0:b0:79f:2cb:868d with SMTP id af79cd13be357-7a34ef456c4mr34831285a.4.1722528432555; Thu, 01 Aug 2024 09:07:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFV3oryN9fC3noWm2U5lGXdwP/vpqahkhLTD//4fU+IWDrX6KSbFmIMVqsVRMfKJJHRzCDlMg== X-Received: by 2002:a05:620a:28d0:b0:79f:2cb:868d with SMTP id af79cd13be357-7a34ef456c4mr34829185a.4.1722528432174; Thu, 01 Aug 2024 09:07:12 -0700 (PDT) Received: from x1n (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a34f6e714fsm2895485a.33.2024.08.01.09.07.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 09:07:11 -0700 (PDT) Date: Thu, 1 Aug 2024 12:07:09 -0400 From: Peter Xu To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, James Houghton , stable@vger.kernel.org, Oscar Salvador , Muchun Song , Baolin Wang Subject: Re: [PATCH v3] mm/hugetlb: fix hugetlb vs. core-mm PT locking Message-ID: References: <20240731122103.382509-1-david@redhat.com> <541f6c23-77ad-4d46-a8ed-fb18c9b635b3@redhat.com> <934885c5-512b-41bf-8501-b568ece34e18@redhat.com> MIME-Version: 1.0 In-Reply-To: <934885c5-512b-41bf-8501-b568ece34e18@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspam-User: X-Rspamd-Queue-Id: 28C004001E X-Rspamd-Server: rspam01 X-Stat-Signature: 7sc4ceedpd67wjts4ocgnkm8y74w88sy X-HE-Tag: 1722528434-895374 X-HE-Meta: U2FsdGVkX1/pRzIPVXfYKN+rXMZcif3wkb/7TB2FCtzae6sTzFccgbFdyArXxkutQt9ETxtZbnfeSbYi/5nm5wgDksPnfjeI8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Xs1V+eYnPY5a67clumRDiIYpIX8bUvptmLilCEzDRV4kJrNJr3hQ+DP+3eVh9U9FE2tP8yhib5ivUbmPRxT/3jzAvmrodmg/ZHSLfw3+Aa+CtA1hVF1QFBuUhylBqCgHRz5pw0XLDezwGvjA0+GclaJkvDn/Jn+OPmkn6uanfpos183c1eIjxSP/0dYdS3HkLRyrFN28VzqpY/dwNyfR1QUEqP/aDAj51EqOrafI= 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 Thu, Aug 01, 2024 at 05:35:20PM +0200, David Hildenbrand wrote: > Hi Peter, [...] > > > + else if (size >= PUD_SIZE) > > > + return pud_lockptr(mm, (pud_t *) pte); > > > + else if (size >= PMD_SIZE || IS_ENABLED(CONFIG_HIGHPTE)) > > > > I thought this HIGHPTE can also be dropped? Because in HIGHPTE it should > > never have lower-than-PMD huge pages or we're in trouble. That's why I > > kept one WARN_ON() in my pesudo code but only before trying to take the pte > > lockptr. > > Then the compiler won't optimize out the ptep_lockptr() call and we'll run > into a build error. And I think the HIGHPTE builderror serves good purpose. > > In file included from : > In function 'ptep_lockptr', > inlined from 'huge_pte_lockptr' at ./include/linux/hugetlb.h:974:9, > inlined from 'huge_pte_lock' at ./include/linux/hugetlb.h:1248:8, > inlined from 'pagemap_scan_hugetlb_entry' at fs/proc/task_mmu.c:2581:8: > ././include/linux/compiler_types.h:510:45: error: call to '__compiletime_assert_256' declared with attribute error: BUILD_BUG_ON failed: IS_ENABLED(CONFIG_HIGHPTE) > 510 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) > | ^ > ././include/linux/compiler_types.h:491:25: note: in definition of macro '__compiletime_assert' > 491 | prefix ## suffix(); \ > | ^~~~~~ > ././include/linux/compiler_types.h:510:9: note: in expansion of macro '_compiletime_assert' > 510 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) > | ^~~~~~~~~~~~~~~~~~~ > ./include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert' > 39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) > | ^~~~~~~~~~~~~~~~~~ > ./include/linux/build_bug.h:50:9: note: in expansion of macro 'BUILD_BUG_ON_MSG' > 50 | BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition) > | ^~~~~~~~~~~~~~~~ > ./include/linux/mm.h:2874:9: note: in expansion of macro 'BUILD_BUG_ON' > 2874 | BUILD_BUG_ON(IS_ENABLED(CONFIG_HIGHPTE)); Ahh.. this is in "ifdef USE_SPLIT_PTE_PTLOCKS" section. I'm thinking maybe we should drop this BUILD_BUG_ON - it says "HIGHPTE shouldn't co-exist with USE_SPLIT_PTE_PTLOCKS", but I think it can? Said that, I think I can also understand your point, where you see ptep_lockptr() a hugetlb-only function, in that case the BUILD_BUG_ON would make sense in hugetlb world. So.. per my previous nitpick suggestion, IIUC we'll need to drop this BUILD_BUG_ON, just to say "USE_SPLIT_PTE_PTLOCKS can work with HIGHPTE" and perhaps slightly more readable; we'll rely on the WARN_ON to guard HIGHPTE won't use pte lock. Either way works for me, thanks! -- Peter Xu