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 2F2AAEB64D8 for ; Wed, 14 Jun 2023 15:31:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC3DA8E0001; Wed, 14 Jun 2023 11:31:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A730D6B007B; Wed, 14 Jun 2023 11:31:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 93B768E0001; Wed, 14 Jun 2023 11:31:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 855B66B0078 for ; Wed, 14 Jun 2023 11:31:16 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 3FAA0AFE2A for ; Wed, 14 Jun 2023 15:31:16 +0000 (UTC) X-FDA: 80901742152.16.029D7AE Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf24.hostedemail.com (Postfix) with ESMTP id 8B9A8180008 for ; Wed, 14 Jun 2023 15:31:11 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZQGNrhs0; spf=pass (imf24.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686756672; 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=SlSsjvlCC2CeUtBnTEzL5Gko2Ykpb9cphhRAoLHObEE=; b=CplBaNMXT4PJTBgtKhd+MDgKJMcQ6PHz5P1yF2AqMiOd2TWIrJ5Dyg6r70T3F13lxNoDII lSBEPJ64ZQKK3jPPpMvkzJGcn7+ZAehWHdrI1/lvGElgAzJZSglXwcW5yfiW0h/wWQfced ZCsWdEP7viF8fD/qp5gYSKOQFkAQSic= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686756672; a=rsa-sha256; cv=none; b=vtH97m47iZS6/j9yk5fm2/p4O/gGrkfirHPA5R0BxTTPbMsPAaxDz8YS/2DsK2h4etlgvV U3S8o+4ztY0vw4OSteAKPebNfJ5s/h5A0/DIxp2wI9GSc59sFmQODhvlE/mnsHpN5y4fUB 17v5DheHGcBB9GNFhY68gpGX0a6cScU= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZQGNrhs0; spf=pass (imf24.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686756671; 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=SlSsjvlCC2CeUtBnTEzL5Gko2Ykpb9cphhRAoLHObEE=; b=ZQGNrhs0cQGHUXM0DmE5mSsH2jOR87mLiqwK+vrv6TgCl1DCrkZQT5CcT+eYZb3IiEOX+K 7m1JJJMLY7G8RrLqdRo3UKQatQ0w/T1CG7wkIhytSWTGbyDn3MCjWobIQwPH7tIfwT5J5s lv5J7ohUJkdytriW8M/YVpObjrk2Oe8= 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-637-eDRF9CSTOqOVSNlqTOjcBQ-1; Wed, 14 Jun 2023 11:31:06 -0400 X-MC-Unique: eDRF9CSTOqOVSNlqTOjcBQ-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-76077669a5aso78231285a.0 for ; Wed, 14 Jun 2023 08:31:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686756666; x=1689348666; 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=SlSsjvlCC2CeUtBnTEzL5Gko2Ykpb9cphhRAoLHObEE=; b=MfSJXlyLIFMzwpOy63KSR+n1ksVNwm9lKFYUkUonjvI5WFDywMuhef4bxjFP8reNSe ZLnC7SyhEBp9EQoK3a9yPpzP1jx/n9rWTQ6v6OAwb7r1oAnBZfLJ9e+xr0jMdydqtDBh 7YQNB5Owbu/5PfTsa5uFkRCdkcLCZm0hEIlxC0gbHQ4yJyHYnm8YSvAjdG3+sIv+ktb0 6r/+moIPR29g+nAR/41RwzVRHmjCaiJbPpzwERiP1G1KzcGQSLMVUgfdrEsK2TtG5Bsk l62ySeju1K3Fnbno2biSouQ1wIZBHvb+A3SHVeNtlarIXODfPdk4JS8QgK8TXN7/kBc6 QqfQ== X-Gm-Message-State: AC+VfDyLgWSj3Cl5+SlGhJiL71Hz1NCKcdlndUwKaNZNCdl8IsqlDd2s gvYKMqP5EOG+jaUQs6pNgJMalJpu3B/SsV3P3DAUID3hNsEiwjR1lTUdIOXC6cDLwNg9O2g1r7z LveXjj9iFxRk= X-Received: by 2002:a05:620a:1923:b0:75e:ce67:c665 with SMTP id bj35-20020a05620a192300b0075ece67c665mr19744452qkb.5.1686756665811; Wed, 14 Jun 2023 08:31:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7SvuLY2mXLOR8xhs4uAme+H5cjdmkliDikMBK1xmNVk1vvvRxU2pKzRVol5pZEqIR5hHYN5w== X-Received: by 2002:a05:620a:1923:b0:75e:ce67:c665 with SMTP id bj35-20020a05620a192300b0075ece67c665mr19744420qkb.5.1686756665467; Wed, 14 Jun 2023 08:31:05 -0700 (PDT) Received: from x1n (cpe5c7695f3aee0-cm5c7695f3aede.cpe.net.cable.rogers.com. [99.254.144.39]) by smtp.gmail.com with ESMTPSA id m2-20020ae9f202000000b00761fae866c7sm980408qkg.76.2023.06.14.08.31.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jun 2023 08:31:04 -0700 (PDT) Date: Wed, 14 Jun 2023 11:31:03 -0400 From: Peter Xu To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Matthew Wilcox , Andrea Arcangeli , John Hubbard , Mike Rapoport , Vlastimil Babka , "Kirill A . Shutemov" , Andrew Morton , Mike Kravetz , James Houghton , Hugh Dickins Subject: Re: [PATCH 4/7] mm/hugetlb: Prepare hugetlb_follow_page_mask() for FOLL_PIN Message-ID: References: <20230613215346.1022773-1-peterx@redhat.com> <20230613215346.1022773-5-peterx@redhat.com> <533c32cf-9a18-1590-4d29-f076d6bd58c1@redhat.com> MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Stat-Signature: 7cmc8uksheewgkr9zu7tyebicus3s87d X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 8B9A8180008 X-Rspam-User: X-HE-Tag: 1686756671-343320 X-HE-Meta: U2FsdGVkX19QwaY0emZZEdvdYb+4ldZ1kyWc2M98YYH7h7SqocDIVV57bfQVLwQD1q94SslSEHIWHEbuydQdWWYOLNrYyGrKqAoleuVHWQircGAn1gPAtJ8NoNIjMDw770N6KWvDW5r1HBgPMU3l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96gDfZmQqY84NVPvei5TvutFaJYU6k+u9/mgJ4AZTlThHVazD4wpNivQObxK49LEpczd+nuLj3/VPu5pV/6hwEcFE9jNKCpA9EO5MF+oxsPq79GmGYJ+seuAgCalREulhJmvT5UWY4B3lt2MxRckg2TizQFaDaT4GPHpjp5xFZsgeaaJqix2JVA7/CyBTiWyUqnP2gPg== 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 Wed, Jun 14, 2023 at 05:17:13PM +0200, David Hildenbrand wrote: > On 14.06.23 17:11, Peter Xu wrote: > > On Wed, Jun 14, 2023 at 04:57:37PM +0200, David Hildenbrand wrote: > > > On 13.06.23 23:53, Peter Xu wrote: > > > > It's coming, not yet, but soon. Loose the restriction. > > > > > > > > Signed-off-by: Peter Xu > > > > --- > > > > mm/hugetlb.c | 7 ------- > > > > 1 file changed, 7 deletions(-) > > > > > > > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > > > > index f037eaf9d819..31d8f18bc2e4 100644 > > > > --- a/mm/hugetlb.c > > > > +++ b/mm/hugetlb.c > > > > @@ -6467,13 +6467,6 @@ struct page *hugetlb_follow_page_mask(struct vm_area_struct *vma, > > > > spinlock_t *ptl; > > > > pte_t *pte, entry; > > > > - /* > > > > - * FOLL_PIN is not supported for follow_page(). Ordinary GUP goes via > > > > - * follow_hugetlb_page(). > > > > - */ > > > > - if (WARN_ON_ONCE(flags & FOLL_PIN)) > > > > - return NULL; > > > > - > > > > hugetlb_vma_lock_read(vma); > > > > pte = hugetlb_walk(vma, haddr, huge_page_size(h)); > > > > if (!pte) > > > Did you fix why the warning was placed there in the first place? (IIRC, at > > > least unsharing support needs to be added, maybe more) > > > > Feel free to have a look at patch 2 - it should be done there, hopefully in > > the right way. And IIUC it could be a bug to not do that before (besides > > CoR there was also the pgtable permission checks that was missing). More > > details in patch 2's commit message. Thanks, > > Oh, that slipped my eyes (unsharing is not really a permission check) -- and I think it is still a "permission check"? It means, we forbid anyone R/O taking the page if it's not exclusively owned, just like we forbid anyone RW taking the page if it's not writable? It's just that the permission check only applies to PIN which follow_page() doesn't yet care, so it won't ever trigger. > the patch description could have been more explicit about why we can now > lift the restrictions. > > For the records: we don't use CoR terminology upstream. As suggested by > John, we use "GUP-triggered unsharing". Sure. > > As unsharing only applies to FOLL_PIN, it doesn't quite fit into patch #2. > Either move that to this patch or squash both. Sure, no strong opinions here. The plan is _if_ someone wants to backport patch 2, this patch should not be part of it. But then maybe it makes more sense to move the CoR change there into this one, not because "it's not permission check", but because CoR is not relevant in follow_page(), so not relevant to a backport. -- Peter Xu