Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp1375537rwl; Thu, 5 Jan 2023 12:39:06 -0800 (PST) X-Google-Smtp-Source: AMrXdXva+IrEP92JmSohFAnizpE89Lvxa6j1lhsrutBthAy3UjPXcpIsBlAKuwcaoCD6yhYHCAtG X-Received: by 2002:a17:906:158c:b0:7c4:f752:e959 with SMTP id k12-20020a170906158c00b007c4f752e959mr42681543ejd.33.1672951146498; Thu, 05 Jan 2023 12:39:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672951146; cv=none; d=google.com; s=arc-20160816; b=05dWDevcyUxitAC9xIVng0w/OV/QDvFIbKzFuqwvVCfDHGXw1TNVdXjk8Sn0lhXtOx ov4zB5nTsW+fBErpuCLKTCBrtWk35OsCRlp39IPRa5lqSkHpvNpmeBZkdHPEwDBl6Fwp uWHCKtKCmWiP6K/iArw7h3PQPJfGUW6E3jqLDRtNwZnTlhlC0ENfEEUdq7AiQSYdp9qF drBJKwwddYHQFrANUejq5F80FS/7LKjMmALeYmV21mCoZ1IojXkYg/J6yRpR8oGvoEfX lyorUVdcFwq1Az6D/RFR2fc//O6yUr9eGACVQpN+qy4EiHAO+rbuDw8kL9mRnnacRdCS 6y8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=1AztRxqvsi6T4hudCdqABGgSTqQjaAiuEjAa9BRqIU4=; b=yX2436NA225q2b3vO+RKzz0VV70YjAFS9Z29lRXraqT4s4HEeUl6a68HR8lKVVZhZK P9uPsozYjtskZfv43KY5DuTw2i8IwywhOCk0zB3nOOoG7ZZQ1TEEiA0/xp3WWn6Npguu UmWhFUBOIOiW48hrS5opKFIQQ8p4UpLfr7nWUT7tvt9FWB8fECoYybr95iDZQ1xJQyBT UxLDduesuujzm9AwBgOwNNVl5jrhA3SpV5dULkB4OPuLOn4e3aP4talU308PCjbaTZt6 p9z8+mc/TR/S2t0w1ej8EGfNzYneiopzTI+c4ZIJocL885NRWzMfrWfokWCCLvm4Lhxm U3wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MrsuVrTC; 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 fj4-20020a1709069c8400b0084cd9dba32esi10665688ejc.974.2023.01.05.12.38.53; Thu, 05 Jan 2023 12:39:06 -0800 (PST) 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=MrsuVrTC; 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 S235562AbjAEUBU (ORCPT + 55 others); Thu, 5 Jan 2023 15:01:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235523AbjAEUBS (ORCPT ); Thu, 5 Jan 2023 15:01:18 -0500 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 DE2EE637A for ; Thu, 5 Jan 2023 12:00:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672948830; 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=1AztRxqvsi6T4hudCdqABGgSTqQjaAiuEjAa9BRqIU4=; b=MrsuVrTCtPuZP55P4/R+DhAcPO1PtUsYUhj7aqGxyjMvRuq+9XFukXMjLdr1C9cTfMaYno NrB1mZiMJ6C3E1If6E898+OhMrMY+lvB+Bp3b3vvw3JpNifgd1BXj1+f+IkYXyAgSTp9+F S6+qRiWsbTaRloZsHiQX4QlUcMRxmUI= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-391-p4XV1UuhPFmCmtwJTG40_A-1; Thu, 05 Jan 2023 15:00:26 -0500 X-MC-Unique: p4XV1UuhPFmCmtwJTG40_A-1 Received: by mail-qk1-f197.google.com with SMTP id o13-20020a05620a2a0d00b006cf9085682dso25726455qkp.7 for ; Thu, 05 Jan 2023 12:00:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=1AztRxqvsi6T4hudCdqABGgSTqQjaAiuEjAa9BRqIU4=; b=NS9ZbD4UwwSV1g7PVU5Q62OPvEal8Gk6dZnVBhSd1T0wypR8suz/FFXAr2IlAOBSb2 r+qzxoURFKx0pRjyQ/fUylL56GCeXcsmRJ3GH2cer4lgcXtpfbuDzj+LUKtm04cuyb5d WIGtlRu8U3dAkv+3ePvKFlXNMqEl2ZRBC3N3t0djTqJdQRC5jSy+lhNO8I1NiODZUeOt c9eXoXWHvZEBb/tZSvIQ1kYK971s1aXCAkpi/hzqDCutqvyGPO0AkZgAfrIo6JZ1V+Hp 3TV6h5Aty50Aai5FqOjlvWUqyjxPshUKZYnT5HNJYnhwpQPjaP1xoBxgq8lNXdRXsG3a Rcdg== X-Gm-Message-State: AFqh2krvodnLwMr9QDCFXD2K0soVCbaqyfIfvOonmWst+K+G4dp/43bv 7JLeIrpOQGebbtfMFXs+bHRfxF2++BIw2awWIyPfluvAg4PwqtCM0XRHGq/HKsfq0k1kKoVm72H r0nCBJJQENNs/8nuoXF4s0Mpt X-Received: by 2002:a05:622a:59cb:b0:3a9:80b6:4c9c with SMTP id gc11-20020a05622a59cb00b003a980b64c9cmr74557601qtb.47.1672948826296; Thu, 05 Jan 2023 12:00:26 -0800 (PST) X-Received: by 2002:a05:622a:59cb:b0:3a9:80b6:4c9c with SMTP id gc11-20020a05622a59cb00b003a980b64c9cmr74557563qtb.47.1672948825962; Thu, 05 Jan 2023 12:00:25 -0800 (PST) Received: from x1n (bras-base-aurron9127w-grc-39-70-52-228-144.dsl.bell.ca. [70.52.228.144]) by smtp.gmail.com with ESMTPSA id gc11-20020a05622a59cb00b003a50d92f9b4sm22226580qtb.1.2023.01.05.12.00.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 12:00:25 -0800 (PST) Date: Thu, 5 Jan 2023 15:00:23 -0500 From: Peter Xu To: James Houghton Cc: Mike Kravetz , Muchun Song , Axel Rasmussen , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] hugetlb: unshare some PMDs when splitting VMAs Message-ID: References: <20230104231910.1464197-1-jthoughton@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230104231910.1464197-1-jthoughton@google.com> 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, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 Wed, Jan 04, 2023 at 11:19:10PM +0000, James Houghton wrote: > PMD sharing can only be done in PUD_SIZE-aligned pieces of VMAs; > however, it is possible that HugeTLB VMAs are split without unsharing > the PMDs first. > > Without this fix, it is possible to hit the uffd-wp-related WARN_ON_ONCE > in hugetlb_change_protection [1]. The key there is that > hugetlb_unshare_all_pmds will not attempt to unshare PMDs in > non-PUD_SIZE-aligned sections of the VMA. > > It might seem ideal to unshare in hugetlb_vm_op_open, but we need to > unshare in both the new and old VMAs, so unsharing in > hugetlb_vm_op_split seems natural. > > [1]: https://lore.kernel.org/linux-mm/CADrL8HVeOkj0QH5VZZbRzybNE8CG-tEGFshnA+bG9nMgcWtBSg@mail.gmail.com/ > > Fixes: 6dfeaff93be1 ("hugetlb/userfaultfd: unshare all pmds for hugetlbfs when register wp") > Signed-off-by: James Houghton Acked-by: Peter Xu Thanks, -- Peter Xu