Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1149273rwe; Sat, 27 Aug 2022 01:37:46 -0700 (PDT) X-Google-Smtp-Source: AA6agR4fiwTVCAsynfNpqQA68muFFlRLDJid/wy26MB14rASqyajOPNthoFQslSTZxB/akWY5qpc X-Received: by 2002:a05:6a00:e16:b0:537:40a7:b095 with SMTP id bq22-20020a056a000e1600b0053740a7b095mr7543164pfb.64.1661589466392; Sat, 27 Aug 2022 01:37:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661589466; cv=none; d=google.com; s=arc-20160816; b=x+Ea9FWYlaSU2X2+ft0Y4q2CzODyLXSxIQBlgyZH3J/I5/RvZ9ESKlN73JkG23zgV3 r9y7Y5W+vACHCYTgPPf71MUPatlCeltrX2VqM4yUALIVKugQ7ZD/T5XB3dVW2VkvcEXB G1IVCu2loeuc10/XUwRdRXo2aPrtKaRnCW/IO7ZD3zlSigaigyrOCeTFKhykOpjWWhcH E6xVGUB2A0I0VyKIdHBJ51EiZ9XmgyTUZgiNvo6IRkGpKl7zjuluQJqZhqQwcWS6jyCv 5XVP8lOypGDUnZq1zfbFIZe2tMz7ENIj6aRYF+0QaCQPzOn6xPoM8x6vOdHONAepCHt4 GNyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=gEVIJj4ViukWpUZrnkHawnoEcoI2g55VIWpxLT514sc=; b=xv1+1b5gVlEzX9kuJBUz9D5v9tRnviszgOOD18e1R18ndHHGDsJGDKaRcVptDa0Eoj Fg7TlLW2JBx7o+GqVsTjkQysQ1pSTcgxk8JMFoL0iOvdO1wIXWK6ba0jdZa5IkSCM8n0 elKdCpSR9jJ9j1XBYfz57L9MJFGGeeSJsinHXdVdFwHqKM4RHSCPLlQc4lI1RvJTwjBA bxwhxkajHj+7GLCN625dutSNI16boLo0b2kdlQJpJP30fGjctNyXvHoG5sdA1rJhYtAP KH3zoz4rq9JAoy6eQbkiblAHqZz/yp8jvY463cav2KdFxoLYCD0rNR0e0PfOy0X/a1FG V2uw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i2-20020a17090a058200b001fb2e4446c1si3684523pji.106.2022.08.27.01.37.35; Sat, 27 Aug 2022 01:37:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231890AbiH0IHn (ORCPT + 99 others); Sat, 27 Aug 2022 04:07:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231222AbiH0IHl (ORCPT ); Sat, 27 Aug 2022 04:07:41 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B984A55AA for ; Sat, 27 Aug 2022 01:07:40 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4MF8Qp5dnWzGprB; Sat, 27 Aug 2022 16:05:54 +0800 (CST) Received: from [10.174.177.76] (10.174.177.76) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sat, 27 Aug 2022 16:07:31 +0800 Subject: Re: [PATCH 5/8] hugetlb: rename vma_shareable() and refactor code To: Mike Kravetz CC: Muchun Song , David Hildenbrand , Michal Hocko , Peter Xu , Naoya Horiguchi , "Aneesh Kumar K . V" , Andrea Arcangeli , "Kirill A . Shutemov" , Davidlohr Bueso , Prakash Sangappa , James Houghton , Mina Almasry , Pasha Tatashin , Axel Rasmussen , Ray Fucillo , Andrew Morton , Linux-MM , linux-kernel References: <20220824175757.20590-1-mike.kravetz@oracle.com> <20220824175757.20590-6-mike.kravetz@oracle.com> From: Miaohe Lin Message-ID: <98db8106-77cf-291d-9642-e429b8b33160@huawei.com> Date: Sat, 27 Aug 2022 16:07:31 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20220824175757.20590-6-mike.kravetz@oracle.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/8/25 1:57, Mike Kravetz wrote: > Rename the routine vma_shareable to vma_addr_pmd_shareable as it is > checking a specific address within the vma. Refactor code to check if > an aligned range is shareable as this will be needed in a subsequent > patch. > > Signed-off-by: Mike Kravetz LGTM. Thanks. Reviewed-by: Miaohe Lin Thanks, Miaohe Lin > --- > mm/hugetlb.c | 19 +++++++++++++------ > 1 file changed, 13 insertions(+), 6 deletions(-) > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index a6eb46c64baf..758b6844d566 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -6648,26 +6648,33 @@ static unsigned long page_table_shareable(struct vm_area_struct *svma, > return saddr; > } > > -static bool vma_shareable(struct vm_area_struct *vma, unsigned long addr) > +static bool __vma_aligned_range_pmd_shareable(struct vm_area_struct *vma, > + unsigned long start, unsigned long end) > { > - unsigned long base = addr & PUD_MASK; > - unsigned long end = base + PUD_SIZE; > - > /* > * check on proper vm_flags and page table alignment > */ > - if (vma->vm_flags & VM_MAYSHARE && range_in_vma(vma, base, end)) > + if (vma->vm_flags & VM_MAYSHARE && range_in_vma(vma, start, end)) > return true; > return false; > } > > +static bool vma_addr_pmd_shareable(struct vm_area_struct *vma, > + unsigned long addr) > +{ > + unsigned long start = addr & PUD_MASK; > + unsigned long end = start + PUD_SIZE; > + > + return __vma_aligned_range_pmd_shareable(vma, start, end); > +} > + > bool want_pmd_share(struct vm_area_struct *vma, unsigned long addr) > { > #ifdef CONFIG_USERFAULTFD > if (uffd_disable_huge_pmd_share(vma)) > return false; > #endif > - return vma_shareable(vma, addr); > + return vma_addr_pmd_shareable(vma, addr); > } > > /* >