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 22B7FC43334 for ; Wed, 29 Jun 2022 06:09:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7024D6B0071; Wed, 29 Jun 2022 02:09:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B0216B0072; Wed, 29 Jun 2022 02:09:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 59E738E0001; Wed, 29 Jun 2022 02:09:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 4BAAA6B0071 for ; Wed, 29 Jun 2022 02:09:44 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1A5CD2130D for ; Wed, 29 Jun 2022 06:09:44 +0000 (UTC) X-FDA: 79630247088.25.13549B1 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by imf05.hostedemail.com (Postfix) with ESMTP id 93AAA100034 for ; Wed, 29 Jun 2022 06:09:41 +0000 (UTC) Received: by mail-pf1-f181.google.com with SMTP id k9so4889320pfg.5 for ; Tue, 28 Jun 2022 23:09:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ErSVijo4gWjx6UrCAwONPztAe8R2oF0W85jecg+exAw=; b=STRTs5aHz8sCESg4GzZ3Z3aIdi9WYtSo/2nhppvil81gcwVOiSJFW77LZFaMT95quA EeFxz50WUWso2tAZvKmg3POssQK7WT+ZQU3zVibVe4MTzKI58Io0BxE2SMPb98Fn+24O 9RZuBlP6Mro9S/FTu5eZN2o91ggvIIwpCuJ7LM9S5zx7tzuwI3Ve+9fFcpr6xT+5YmaP jbkphfmbsw9QF4pExdTL7/5Zc7eJ8+ogju1hhRn45y1UqDzW8lE8n1paZOB7hxlhPCYP f33eMJYihfK9KNbC/e2QQFxytx4Qanab0kC74s6xe8GKs2fVHidmd5Lu8IpbY9LsTFzf I/nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ErSVijo4gWjx6UrCAwONPztAe8R2oF0W85jecg+exAw=; b=pq+8wn2qkjhZkkU4PIaa4bsHPVSe3H9obYLw8gFAakWsgc2F+gTodolHqFGXPFZyuE FP8zgC0FM3+zUgIzfeuzNk76odqrxpe2iOc2HOPh2R76Yqb39qjT9pCmW12RYzkU6+Qc TggOist63JVGQ7pjH0BQBK1pTP/K+/msV2EFP5tQKblhzggf/zSpC2biBfEGM1z9cA96 T/gEY/QzniSZ+GDOrf+V4rXmNsbBR2blYPlejbF1JPDKb5FSTn4xr+dtH63viOiqNqTP gWf4KryWIMy5fMxWN4yI/UkuMTeJIP5+RGmWjrZxBZCJnfBtEU/9CAjcPqikt769ZbQH xndw== X-Gm-Message-State: AJIora/6mvQpG7CtVfDd/y5s9qJT7sFJ23LwVUWZdl9REhOqLpHptLMP 6HcrYx6j7PXPDA4SLWsClHw0jA== X-Google-Smtp-Source: AGRyM1sZ3ol/YQTUAxlsQmxuakEsImj5mW2Jtdib3RUM/ulJPF7vMpcU1RBoGr0OwaHlE8u11GeaRQ== X-Received: by 2002:a63:6e44:0:b0:40c:73a7:b6c9 with SMTP id j65-20020a636e44000000b0040c73a7b6c9mr1587570pgc.285.1656482980262; Tue, 28 Jun 2022 23:09:40 -0700 (PDT) Received: from localhost ([139.177.225.245]) by smtp.gmail.com with ESMTPSA id n63-20020a17090a5ac500b001ec8c53544esm1018126pji.46.2022.06.28.23.09.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 23:09:39 -0700 (PDT) Date: Wed, 29 Jun 2022 14:09:35 +0800 From: Muchun Song To: Mike Kravetz Cc: James Houghton , Peter Xu , David Hildenbrand , David Rientjes , Axel Rasmussen , Mina Almasry , Jue Wang , Manish Mishra , "Dr . David Alan Gilbert" , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 04/26] hugetlb: make huge_pte_lockptr take an explicit shift argument. Message-ID: References: <20220624173656.2033256-1-jthoughton@google.com> <20220624173656.2033256-5-jthoughton@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656482983; a=rsa-sha256; cv=none; b=PXRHTsr6Fav5FKWW79dd1Rncx8OSlz3gm/wrimbQ/0JghFyOiaZK9B57xT35zkuk9/aaPN s2D1YvMYInyGg/n1+shLiWrwJEAx9/YGMiH7w3hAMgPiDHeFqgHOpif3miUcyrlldaYtK/ ucYyKRm8FDWY0o3CsAI2oP/Eoc+fz38= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=STRTs5aH; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf05.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.210.181 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656482983; 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=ErSVijo4gWjx6UrCAwONPztAe8R2oF0W85jecg+exAw=; b=FXuoSDVc6LNvBEYFhUY13v4QIrITjfzH2qQnKFH49IMc4DfMH1CxHf0o0xO94frTH1oHm1 JtAtGmV1qthMDUWFZblnP4HCrUEMRIFcGgtz62fLZvavJ784ILiYB8R/tJeLHg7L0GMWKY zr/JgRfLlQx2PjwcxSDDbzmQWAzGwjE= X-Stat-Signature: 9bubmngpcdux3otgaun8ahdugq9yxao1 X-Rspam-User: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 93AAA100034 Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=STRTs5aH; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf05.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.210.181 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-HE-Tag: 1656482981-406903 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: On Mon, Jun 27, 2022 at 01:51:53PM -0700, Mike Kravetz wrote: > On 06/24/22 17:36, James Houghton wrote: > > This is needed to handle PTL locking with high-granularity mapping. We > > won't always be using the PMD-level PTL even if we're using the 2M > > hugepage hstate. It's possible that we're dealing with 4K PTEs, in which > > case, we need to lock the PTL for the 4K PTE. > > I'm not really sure why this would be required. > Why not use the PMD level lock for 4K PTEs? Seems that would scale better > with less contention than using the more coarse mm lock. > Your words make me thing of another question unrelated to this patch. We __know__ that arm64 supports continues PTE HugeTLB. huge_pte_lockptr() did not consider this case, in this case, those HugeTLB pages are contended with mm lock. Seems we should optimize this case. Something like: diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 0d790fa3f297..68a1e071bfc0 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -893,7 +893,7 @@ static inline gfp_t htlb_modify_alloc_mask(struct hstate *h, gfp_t gfp_mask) static inline spinlock_t *huge_pte_lockptr(struct hstate *h, struct mm_struct *mm, pte_t *pte) { - if (huge_page_size(h) == PMD_SIZE) + if (huge_page_size(h) <= PMD_SIZE) return pmd_lockptr(mm, (pmd_t *) pte); VM_BUG_ON(huge_page_size(h) == PAGE_SIZE); return &mm->page_table_lock; I did not check if elsewhere needs to be changed as well. Just a primary thought. Thanks. > -- > Mike Kravetz >