From patchwork Tue Jun 13 21:53:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 107581 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp847228vqr; Tue, 13 Jun 2023 15:00:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6btLD3wqHMvrDCvxilqHb4EzHVfQQw+RBGo87BMYCtJJOJDsiKTy2+YFGwloA9iaOOF3GR X-Received: by 2002:a17:907:2cc3:b0:978:8f29:8c85 with SMTP id hg3-20020a1709072cc300b009788f298c85mr13241157ejc.32.1686693615629; Tue, 13 Jun 2023 15:00:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686693615; cv=none; d=google.com; s=arc-20160816; b=erGy2XI47MuYydFy1FD9nF/ucIu09KNsKh2NmtSMbdnkT5jMHUBS+dqIg+4i10Hr6T Md2KWk7aKkxRpQ8wKjB4duZz7GUICBlXvK/fyyCM0X5KngAylEIccoN1uhFU3gUHayaj sSXJzF91hnO6cgQpfATqd9wP60+uXLvhiFNLLrOjF19vEOuBiNoPhOaoe4364I5zMTR4 91U7Okz91oHbDP0HFl5OBm5f4cU1d89tEVdfjp3s5sYGZZud75JF39IupfPr0GE/rBfy kkMU2kWj5ZeehQmpBqtM6WeEpfoaV6+X37hf/fubNPLpGZuUFntmX2TOzd2nKFFaZtDc pV6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=V6YucMw264yJynzunMB03zc5mw1fxLam6CUcenZWneI=; b=E4AOJA+M6IhVZ0bh0Sc/oHvAur5DFYLkPQjoEQ3vD766xMKKgztY42G5SZRQdMhtjX eqkSn2w8dxlpkk60bMzDurL+2TeO8EdSm+3s/NhUC+Eoplz/7hljNqpSY8jmVaSgwPTQ 2AN7vrpV8YVQwBtV1PlCe20+sdWQskf7h5z1yxiBBXfGXOZnMHMAXSdZxWnSPfmE4BwS VFCZ6EH2jbCCQXiVDQCYBcbvM4YCWIAXGzrezPNn0cEiRHwKFdY3h1k30FJWQZci0s/U 8OC5ZVjEsWUkdeKazoUtEwKfcVMFg/wzCWdUoIoj9JfxqVJKOGqJ70NQ/r4/Ja+ov1ji /UKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=atXrYasO; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p16-20020a170906839000b009745659639csi7140776ejx.814.2023.06.13.14.59.48; Tue, 13 Jun 2023 15:00:15 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=atXrYasO; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236598AbjFMV47 (ORCPT + 99 others); Tue, 13 Jun 2023 17:56:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235428AbjFMVyp (ORCPT ); Tue, 13 Jun 2023 17:54:45 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D57D1BD2 for ; Tue, 13 Jun 2023 14:54:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686693242; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=V6YucMw264yJynzunMB03zc5mw1fxLam6CUcenZWneI=; b=atXrYasODl2oXtPLbheyd6azWyJUXfhCX6jCuYWCwWqA+Qn4LydDg+h05g5rzSmXV8z4dX N+aQzuY/wS3FqApB04/zl5RY7bQU8zG6hxX+VAygIqLvl5veDYqzmUJ6m/06O32af7esuW ojqyLioy+UgTqFwKrYDvKqHtlMXB1kQ= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-549-L0cxunivNc21UapB-J4I-Q-1; Tue, 13 Jun 2023 17:54:00 -0400 X-MC-Unique: L0cxunivNc21UapB-J4I-Q-1 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-3fb2e6ca6eeso2354251cf.1 for ; Tue, 13 Jun 2023 14:53:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686693237; x=1689285237; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=V6YucMw264yJynzunMB03zc5mw1fxLam6CUcenZWneI=; b=WNC8qqe0DZkcuAguAYOKdFggas8kHMIBAOP64vBQHaWKnJW0UqTb9T9mJ5fISW7qp7 dM2ybkf/tC1k1/jstkvpVNJLpnmeCACWzmWSyXw1ilfC9OCFXn1VbJEiY2+DzYPugwni X9Cijbpw83d44ZyLsmr5OthbczeTr+EtjK0yDhwrY3EQZkMXdf4jShfe4eszJkS4DXlu IzBo/kFsccqyPZsOD85RIodK6WFOOyMK6B5r/fPVmpAUP9rW8wL1JOLKzQNTKU+uMaa3 3qroVFYRuMOhQahu781Q+MzzHVG0DXLzmDRwwjFzMzm6YPQFQaUXMGpG4Squ0tuTKHky NEmQ== X-Gm-Message-State: AC+VfDzlU98rLvpCaLvgRD6PxcY1aJ9Y5SBAAfDP1emFwbfaLfzHG0P+ bzq+NeXkQfwBX9XwSUxIUNWBJfTRcc5hJotkvXhuowx0vMQJcWh9ukTGoaKW1JMkAdKADKmNTLQ 8uIC0sT4RA0wWFnc1e35HDevFUxbCjTfjOZcskHIDFoPUTQ14P4/I93qochMiOd9mVnnkdvi0bp iXrjl9uw== X-Received: by 2002:ac8:5c4e:0:b0:3f6:b556:7c97 with SMTP id j14-20020ac85c4e000000b003f6b5567c97mr18596651qtj.4.1686693237116; Tue, 13 Jun 2023 14:53:57 -0700 (PDT) X-Received: by 2002:ac8:5c4e:0:b0:3f6:b556:7c97 with SMTP id j14-20020ac85c4e000000b003f6b5567c97mr18596618qtj.4.1686693236845; Tue, 13 Jun 2023 14:53:56 -0700 (PDT) Received: from x1n.redhat.com (cpe5c7695f3aee0-cm5c7695f3aede.cpe.net.cable.rogers.com. [99.254.144.39]) by smtp.gmail.com with ESMTPSA id fz24-20020a05622a5a9800b003f9bccc3182sm4522330qtb.32.2023.06.13.14.53.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jun 2023 14:53:56 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Matthew Wilcox , Andrea Arcangeli , John Hubbard , Mike Rapoport , David Hildenbrand , Vlastimil Babka , peterx@redhat.com, "Kirill A . Shutemov" , Andrew Morton , Mike Kravetz , James Houghton , Hugh Dickins Subject: [PATCH 3/7] mm/hugetlb: Add page_mask for hugetlb_follow_page_mask() Date: Tue, 13 Jun 2023 17:53:42 -0400 Message-Id: <20230613215346.1022773-4-peterx@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230613215346.1022773-1-peterx@redhat.com> References: <20230613215346.1022773-1-peterx@redhat.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768626444681853677?= X-GMAIL-MSGID: =?utf-8?q?1768626444681853677?= follow_page() doesn't need it, but we'll start to need it when unifying gup for hugetlb. Signed-off-by: Peter Xu Reviewed-by: Mike Kravetz Reviewed-by: David Hildenbrand --- include/linux/hugetlb.h | 8 +++++--- mm/gup.c | 3 ++- mm/hugetlb.c | 4 +++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 21f942025fec..0d6f389d98de 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -131,7 +131,8 @@ int move_hugetlb_page_tables(struct vm_area_struct *vma, int copy_hugetlb_page_range(struct mm_struct *, struct mm_struct *, struct vm_area_struct *, struct vm_area_struct *); struct page *hugetlb_follow_page_mask(struct vm_area_struct *vma, - unsigned long address, unsigned int flags); + unsigned long address, unsigned int flags, + unsigned int *page_mask); long follow_hugetlb_page(struct mm_struct *, struct vm_area_struct *, struct page **, unsigned long *, unsigned long *, long, unsigned int, int *); @@ -297,8 +298,9 @@ static inline void adjust_range_if_pmd_sharing_possible( { } -static inline struct page *hugetlb_follow_page_mask(struct vm_area_struct *vma, - unsigned long address, unsigned int flags) +static inline struct page *hugetlb_follow_page_mask( + struct vm_area_struct *vma, unsigned long address, unsigned int flags, + unsigned int *page_mask) { BUILD_BUG(); /* should never be compiled in if !CONFIG_HUGETLB_PAGE*/ } diff --git a/mm/gup.c b/mm/gup.c index aa0668505d61..8d59ae4554e7 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -794,7 +794,8 @@ static struct page *follow_page_mask(struct vm_area_struct *vma, * Ordinary GUP uses follow_hugetlb_page for hugetlb processing. */ if (is_vm_hugetlb_page(vma)) - return hugetlb_follow_page_mask(vma, address, flags); + return hugetlb_follow_page_mask(vma, address, flags, + &ctx->page_mask); pgd = pgd_offset(mm, address); diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 9c261921b2cf..f037eaf9d819 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -6457,7 +6457,8 @@ static inline bool __follow_hugetlb_must_fault(struct vm_area_struct *vma, } struct page *hugetlb_follow_page_mask(struct vm_area_struct *vma, - unsigned long address, unsigned int flags) + unsigned long address, unsigned int flags, + unsigned int *page_mask) { struct hstate *h = hstate_vma(vma); struct mm_struct *mm = vma->vm_mm; @@ -6506,6 +6507,7 @@ struct page *hugetlb_follow_page_mask(struct vm_area_struct *vma, * because we hold the ptl lock and have verified pte_present(). */ WARN_ON_ONCE(try_grab_page(page, flags)); + *page_mask = huge_page_mask(h); } out: spin_unlock(ptl);