Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2295629rwd; Fri, 16 Jun 2023 01:52:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7tvo9Evhjdr7oLJQy/6n3DKNaeDxMEgNPZ8dS5L107E7/9lBqHMS9yq0+W8Xf0+uBB+Cfm X-Received: by 2002:a05:6a00:21ce:b0:666:64fb:b129 with SMTP id t14-20020a056a0021ce00b0066664fbb129mr1655174pfj.27.1686905547266; Fri, 16 Jun 2023 01:52:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686905547; cv=none; d=google.com; s=arc-20160816; b=SHocIhanGR3L41rS4m7bb4Xhy4W12I4Skc/bu8h0M/uSX6G9GTD174y24AP/0Y3c1f VFKKglBvFTTOJrrBWx1LEyvS3PgmO2voP/wppHMu8l+RR+wvAsHddoNM2+GVwoopTaa6 tTJTGQ29mZXSHMvXUL5/Ysp+pm12+rzjY7fnwKboB2DNZfDU5w5yJmimLMpv39wQCDXR bresWCghJ9WgVxeQlFgjrNWfCLeJ2sN4yM//4bZELSWs6eL+6E/N9EeDLM+qTrQojuuJ Yioj8mr405M5LOm8a4xdtJP5jF0V0XWULyex7C72cRpXG/oE39gujqLeGFZ4aAsh7Xpq v/TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=Gr7a6v7Egyynk2whMDZ85Y4nh+6uiz4a8aewos3ecfU=; b=KwCBY8O/Mapoa5CEHT4C4bPizrBS4OQaQMo5a+PBbP3ChqNNT+cotfLSW1McIiny2S y5L43IxTAPDokebhV9QSscIAwpSF69zijz540j6dzjwSOKOLq5Ovg2e7MbGNZ1FvWVdq rb6Wz2DMW0UFj7TR6QFE8rwwG1QexnPX74aExYSD0OFdLwNZWFqqApvAlOLkYDHhuLuZ 82a3Wyb91JYv0O5oDwvjuDtlZUGTMNkWWhub6+hXaUt4IK0YeDzC+J7fiNcwys+lFe/s v+b9LQPbSF9f9dS1SKSxoNwe3QWMCZh1tGrRIFmVhDwhuDL9zaZvvegCRWAGt0X71QYh 55Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dpyOtMEP; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m129-20020a633f87000000b0054ff53233f2si3317827pga.567.2023.06.16.01.52.13; Fri, 16 Jun 2023 01:52:27 -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=dpyOtMEP; 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 S243299AbjFPIJV (ORCPT + 99 others); Fri, 16 Jun 2023 04:09:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241031AbjFPIJQ (ORCPT ); Fri, 16 Jun 2023 04:09:16 -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 70A012117 for ; Fri, 16 Jun 2023 01:08:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686902910; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Gr7a6v7Egyynk2whMDZ85Y4nh+6uiz4a8aewos3ecfU=; b=dpyOtMEP/bqqeT4CMErhAS0owpqA1KGBEt7/kxhpg5otmrg7utDlmFVzjFTcrpTvsaAfuf MtiAblYEu4HzQKgiYUAmhcP7l5KKkIbfFMv370nxlytnvKw9xnkKmoC3cH8XhIzEbAixdq Nli3BCawVT7+4Yb1Hx2gnM3SJdj6bx8= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-177-X2LBpSXpNCa6seMZp0P03Q-1; Fri, 16 Jun 2023 04:08:29 -0400 X-MC-Unique: X2LBpSXpNCa6seMZp0P03Q-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-30e4d85e1ffso538113f8f.0 for ; Fri, 16 Jun 2023 01:08:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686902908; x=1689494908; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Gr7a6v7Egyynk2whMDZ85Y4nh+6uiz4a8aewos3ecfU=; b=D8taFehTgHhb1pvulInUGidaR3rUw+5QucXBn3RbkkZrCXO/qEZeyWVpdBSs163ROm cVPjHaPRyRSYImx54OJmaTZ/U2l22ZxBxpmclyIs03uRXAruI5mf1pKvrEu35mxpDMZV NxhNhMh5PXGN1t1LLACAGIgP1fCNR+oJI8IUmKHIrqyKL6cW2ufcq0HzAkfLYN6PcpX5 lRWitqIAKHuqeqmrmhoYAD4wyWV7V4NmryPBN1rQX3Pzc5nyV2iTw7UCqz0HfhxPwC78 Eg11h+p8bP2nNkmjStWGy8cRf+LA7lXByGzq6nMbDYpZ6MV6xPKjFfoRfFEwwXUEC/dz SU9Q== X-Gm-Message-State: AC+VfDyoswrppxNJ8XGhUyBAgqFZPV4UjbdQOWxYNDGevppDzyFwn2NE anKB/U92Z3p5B+5eWnfpAvppEuJxHq0yIFqR0ET7030TarMUph+PeLkeBpTD3NOjWvGmlQzOwV5 6mjX/nz1J4lUtOuRlGekT4Fru X-Received: by 2002:adf:fe48:0:b0:311:1b34:a7c9 with SMTP id m8-20020adffe48000000b003111b34a7c9mr782832wrs.12.1686902908107; Fri, 16 Jun 2023 01:08:28 -0700 (PDT) X-Received: by 2002:adf:fe48:0:b0:311:1b34:a7c9 with SMTP id m8-20020adffe48000000b003111b34a7c9mr782815wrs.12.1686902907698; Fri, 16 Jun 2023 01:08:27 -0700 (PDT) Received: from ?IPV6:2003:cb:c707:9800:59ba:1006:9052:fb40? (p200300cbc707980059ba10069052fb40.dip0.t-ipconnect.de. [2003:cb:c707:9800:59ba:1006:9052:fb40]) by smtp.gmail.com with ESMTPSA id a8-20020a5d5088000000b0030f9c3219aasm20732258wrt.47.2023.06.16.01.08.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 16 Jun 2023 01:08:27 -0700 (PDT) Message-ID: <9a4b168b-fb27-b4e4-94e9-5a2c1390aa2a@redhat.com> Date: Fri, 16 Jun 2023 10:08:26 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH 1/7] mm/hugetlb: Handle FOLL_DUMP well in follow_page_mask() Content-Language: en-US To: Peter Xu , linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Matthew Wilcox , Andrea Arcangeli , John Hubbard , Mike Rapoport , Vlastimil Babka , "Kirill A . Shutemov" , Andrew Morton , Mike Kravetz , James Houghton , Hugh Dickins References: <20230613215346.1022773-1-peterx@redhat.com> <20230613215346.1022773-2-peterx@redhat.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20230613215346.1022773-2-peterx@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, 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 On 13.06.23 23:53, Peter Xu wrote: > Firstly, the no_page_table() is meaningless for hugetlb which is a no-op > there, because a hugetlb page always satisfies: > > - vma_is_anonymous() == false > - vma->vm_ops->fault != NULL > > So we can already safely remove it in hugetlb_follow_page_mask(), alongside > with the page* variable. > > Meanwhile, what we do in follow_hugetlb_page() actually makes sense for a > dump: we try to fault in the page only if the page cache is already > allocated. Let's do the same here for follow_page_mask() on hugetlb. > > It should so far has zero effect on real dumps, because that still goes > into follow_hugetlb_page(). But this may start to influence a bit on > follow_page() users who mimics a "dump page" scenario, but hopefully in a > good way. This also paves way for unifying the hugetlb gup-slow. > > Signed-off-by: Peter Xu > --- > mm/gup.c | 9 ++------- > mm/hugetlb.c | 9 +++++++++ > 2 files changed, 11 insertions(+), 7 deletions(-) > > diff --git a/mm/gup.c b/mm/gup.c > index dbe96d266670..aa0668505d61 100644 > --- a/mm/gup.c > +++ b/mm/gup.c > @@ -781,7 +781,6 @@ static struct page *follow_page_mask(struct vm_area_struct *vma, > struct follow_page_context *ctx) > { > pgd_t *pgd; > - struct page *page; > struct mm_struct *mm = vma->vm_mm; > > ctx->page_mask = 0; > @@ -794,12 +793,8 @@ static struct page *follow_page_mask(struct vm_area_struct *vma, > * hugetlb_follow_page_mask is only for follow_page() handling here. > * Ordinary GUP uses follow_hugetlb_page for hugetlb processing. > */ > - if (is_vm_hugetlb_page(vma)) { > - page = hugetlb_follow_page_mask(vma, address, flags); > - if (!page) > - page = no_page_table(vma, flags); > - return page; > - } > + if (is_vm_hugetlb_page(vma)) > + return hugetlb_follow_page_mask(vma, address, flags); > > pgd = pgd_offset(mm, address); > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index 270ec0ecd5a1..82dfdd96db4c 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -6501,6 +6501,15 @@ struct page *hugetlb_follow_page_mask(struct vm_area_struct *vma, > spin_unlock(ptl); > out_unlock: > hugetlb_vma_unlock_read(vma); > + > + /* > + * Fixup retval for dump requests: if pagecache doesn't exist, > + * don't try to allocate a new page but just skip it. > + */ > + if (!page && (flags & FOLL_DUMP) && > + !hugetlbfs_pagecache_present(h, vma, address)) > + page = ERR_PTR(-EFAULT); > + > return page; > } > Makes sense to me: Reviewed-by: David Hildenbrand -- Cheers, David / dhildenb