Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1468845rwb; Thu, 15 Dec 2022 10:24:06 -0800 (PST) X-Google-Smtp-Source: AA0mqf7E8UbtpxQWO7mLfS9k0wIk4wD3tdldfIIa2d0gR+kCyAFI1KS1JYCX+SG66L4DqFRZxDyw X-Received: by 2002:a05:6a20:6f08:b0:a2:df6d:e56b with SMTP id gt8-20020a056a206f0800b000a2df6de56bmr14155231pzb.14.1671128646171; Thu, 15 Dec 2022 10:24:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671128646; cv=none; d=google.com; s=arc-20160816; b=awPTMPBdzIfS30PJN3FvN1/19I3tMh05e+4euuc7boNCA5jdDuiJhFazPSop6GRIo4 Wz5IwsThsBL4T6mnxhnfiv4wHNwvoLn0UY25K5JQW4VC8Z1rmpFqflMgLVdBic3sy9vY ncbiJlHo8UJr057s9+pcUBO9Z/jpD4KkUyrOb1uGiSQeTLkfiTF0hvauiGIAGNdIqcGT jhsC6Usl4JroO3rfvkWTrarqPeOg1NbpBkKFRWyJDK6rKTUEdc58x8jxcq5lailu2+Hr l0ZUdGU9l1iitMHq7KcP2RA959rld1vZKF64EFnqpJYA9BqEJvTnEOLcpkm+PvNJIhOH V7ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ByuG98ZwLJHBzjuVb4YMRLtWuLmRZHcl+yVnvda45G0=; b=cPw+kz6JpBC5cuYdAA5/mm+EY+gheEuw5WrZJqVv4OoPZUqCbfIBUIOWdqi+Ebyy+T fo+wBkkW4xrRx0noNF3++syykZF4RBjvzSBcodOYDEse8GIEoE/vbz+y789KAyZ7vjil 1U/QiVngLOaARkKKI3affhKgpb+erkbVmq6B7TeF+95zL1B4urroVAby1PMUzERmUGts 74CZGjNh08QS5azSCd6pBPK/nzxEqa8m4r9gwprmaDpTqB1gpCN0TWlmNoSmwM241XSh 4+0q2MrxMfDlChdVlfRLAGOTlvbq7ob88+R9bAXmkdq5vDAXGtnPG4VNhMzZZ6fmql1c oqAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=fQJxJx2j; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o26-20020a63731a000000b004790f3fc790si69518pgc.510.2022.12.15.10.23.57; Thu, 15 Dec 2022 10:24: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=@google.com header.s=20210112 header.b=fQJxJx2j; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230114AbiLOSIi (ORCPT + 69 others); Thu, 15 Dec 2022 13:08:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229469AbiLOSIg (ORCPT ); Thu, 15 Dec 2022 13:08:36 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 341F13B9C8 for ; Thu, 15 Dec 2022 10:08:35 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id u12so16860wrr.11 for ; Thu, 15 Dec 2022 10:08:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=ByuG98ZwLJHBzjuVb4YMRLtWuLmRZHcl+yVnvda45G0=; b=fQJxJx2j21x6TIPo/MlAFafl25T/N5xrD9/4zOOOsiEgdQMHhBVPl0pgXEWodm+eLH OnbXiUVU3PExydereiUgThfTB/eNQla8/vuW7pl0nvsApbnX5nixk3Z1+9YRdvFT95Ke Onvs28Fb86W24CNLEhmr0kHK0AQGmSEsHnFQdLMuGUB7x/gywUfABssUAobluwUAIaVz tQoP4P2QerB2YeAV5i2J7EYs2ByJvnF1mimxm6DWkiVT7e+M11xPN+982vmd8KAs0y7a d9O0abl4bZ0cDTNHreRtqWuo4Rg6seYesZYRO3/qNuYqIwi8rqtt1gvzv2eoP9jpnfnR +4jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ByuG98ZwLJHBzjuVb4YMRLtWuLmRZHcl+yVnvda45G0=; b=aqoVELS2dJN3nJ7mOgQey7cbmiVkg9eQrT88KydWPsMrbCbFKa8xy76CPQ2l31q/u7 p2eGzZTPL6VQjtAgUwzQY+krOpeUHn8gk0/cmvaeVEWt+AC9usS2scHlvVbPcZBncUgM W9ZB9cQF/s8WInUHOz7c2YIOCKctdeSQ1zKKz4y7uWLsvequfQ95lyjxvAL90MqSPApG f7is0SNB2f6EiXlPJt7yNI2p+aTOIpcXgtS52n6m7geXgToBTA7ndTSRkMrubcTNoH7b kaHm1h09i7sIRSfNlN9KCaR+B/PO8c+5ciQU+/UmqR8gWdUT7LpIpkBQQ+SmTNG2W1tT GNSw== X-Gm-Message-State: ANoB5pkpYivllPi4SeXV5Z3BevmHdKvx3I7rerj2DdfG2AMOK2KLpmfx 9Ztcp84EHjMkpy8+mQ5ur6XqdHrmTX0uSt2hgiwLCA== X-Received: by 2002:a5d:524f:0:b0:242:dee:716c with SMTP id k15-20020a5d524f000000b002420dee716cmr33401675wrc.664.1671127713681; Thu, 15 Dec 2022 10:08:33 -0800 (PST) MIME-Version: 1.0 References: <20221021163703.3218176-1-jthoughton@google.com> <20221021163703.3218176-9-jthoughton@google.com> In-Reply-To: From: James Houghton Date: Thu, 15 Dec 2022 13:08:21 -0500 Message-ID: Subject: Re: [RFC PATCH v2 08/47] hugetlb: add HGM enablement functions To: Mike Kravetz Cc: Muchun Song , Peter Xu , David Hildenbrand , David Rientjes , Axel Rasmussen , Mina Almasry , "Zach O'Keefe" , Manish Mishra , Naoya Horiguchi , "Dr . David Alan Gilbert" , "Matthew Wilcox (Oracle)" , Vlastimil Babka , Baolin Wang , Miaohe Lin , Yang Shi , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 Thu, Dec 15, 2022 at 12:52 PM Mike Kravetz wrote: > > On 12/13/22 10:49, James Houghton wrote: > > On Mon, Dec 12, 2022 at 7:14 PM Mike Kravetz wrote: > > > > > > On 10/21/22 16:36, James Houghton wrote: > > > > Currently it is possible for all shared VMAs to use HGM, but it must be > > > > enabled first. This is because with HGM, we lose PMD sharing, and page > > > > table walks require additional synchronization (we need to take the VMA > > > > lock). > > > > > > Not sure yet, but I expect Peter's series will help with locking for > > > hugetlb specific page table walks. > > > > It should make things a little bit cleaner in this series; I'll rebase > > HGM on top of those patches this week (and hopefully get a v1 out > > soon). > > > > I don't think it's possible to implement MADV_COLLAPSE with RCU alone > > (as implemented in Peter's series anyway); we still need the VMA lock. > > As I continue going through the series, I realize that I am not exactly > sure what synchronization by the vma lock is required by HGM. As you are > aware, it was originally designed to protect against someone doing a > pmd_unshare and effectively removing part of the page table. However, > since pmd sharing is disabled for vmas with HGM enabled (I think?), then > it might be a good idea to explicitly say somewhere the reason for using > the lock. It synchronizes MADV_COLLAPSE for hugetlb (hugetlb_collapse). MADV_COLLAPSE will take it for writing and free some page table pages, and high-granularity walks will generally take it for reading. I'll make this clear in a comment somewhere and in commit messages. It might be easier if hugetlb_collapse() had the exact same synchronization as huge_pmd_unshare, where we not only take the VMA lock for writing, we also take the i_mmap_rw_sem for writing, so anywhere where hugetlb_walk() is safe, high-granularity walks are also safe. I think I should just do that for the sake of simplicity. - James > -- > Mike Kravetz