Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4885083iob; Mon, 9 May 2022 04:04:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpdBaOFwYJHh3B+rbtElXWAmCX4Tq2ozS1tUGBxWBnUM7OOjFFsBBpARchybO1ppGyTpUv X-Received: by 2002:a17:902:e808:b0:15e:b27b:9302 with SMTP id u8-20020a170902e80800b0015eb27b9302mr15831594plg.54.1652094294220; Mon, 09 May 2022 04:04:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652094294; cv=none; d=google.com; s=arc-20160816; b=go2J3jLggnGIQrGd09K0HqMex6lv5TjzHF15I1SzP2aiyLXugDMd1ZazSOQu+mPbzT w8IeKnlDFhWLPiVwRKEyE2RJs3PoU/11Kv2MKHyV7VuIAbI8lKi3WaKeW0BgIC+rCEd/ 4JeljRgGRx8gyr6xebXEo8ExkzRd66QpaVpXGE5gmd7b4+lYPdza3W2koBVPB/Rzc0XL 5UQslLfCwM6fNUZ4RRVxvAVByU+kYvYK62BysGxOSWQfv914offyux8QK1QxGH4+x604 UlqZbxhKpH7FCUehR/+OkXr24Caiu+qfQc+QQVpE/GG+m8F9WqWkN6DnHkPfTimMpvrn jEIA== 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=PmPqsk4Ds+rkfpu3nL2hTmPZ4zZI7ndI1Rv+jcAXn+g=; b=zsPtNQ0YslUc0n3pjZUz1puBgD3sW5OPwg+xciLswDAdBV3Fu5EBPjEQ/3B6/uN5Gc dgyzVJKyEtm7xc2oL5PUV8xfDJLBCjKhaEd6Lr1X2Un/gxO20SQEyzyVNp2Rzkk0XF7F ZbSY9q3DlE4NrbgO2R+RhhqqJlPzoIhwE3ow9Fk6mRx47cdWfW+0IKBrtuO9j4atNt6/ wDU7MBbQl5F8c5wJJ2Agbng37e5AwV2hIb1geBAfMbzKYKew8By3L3cqh2CP7UMwI4Hv e4Ozvp9XtJxl84fneYwrOqv627CqUkWKbL5Wnji0NNyOWps0/IKNx4NKucgmXFH+GQ2z R4bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=SyLOThmL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id i8-20020aa796e8000000b0050dc2c62201si12777771pfq.65.2022.05.09.04.04.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 04:04:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=SyLOThmL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 93735285EE0; Mon, 9 May 2022 03:20:10 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233552AbiEHNfx (ORCPT + 99 others); Sun, 8 May 2022 09:35:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233550AbiEHNft (ORCPT ); Sun, 8 May 2022 09:35:49 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0034B101D2 for ; Sun, 8 May 2022 06:31:57 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id r9so10958668pjo.5 for ; Sun, 08 May 2022 06:31:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=PmPqsk4Ds+rkfpu3nL2hTmPZ4zZI7ndI1Rv+jcAXn+g=; b=SyLOThmLnXTk6qRKX1oo9DRLScsXkpBQJcjqc2ZX8BklsBr9Jd5/4XzS5R0rdBNn64 Gj08t8HnQPHGWv/6lK5azajHcMs4BDXMAWO/si9Vg++doIk4TwR6gjg96i/2Ieo239U+ GD/hhn1ajJzQO2Fu00Id46ibFUBWFedLdoweGjfehLyxDpd+kx2jhOMeAvgK4hJi70uy 2Sxen0AzDNegfxiv3X3keWQqOByVGhCLH68rwxiyhvd4lp5cQorNpjcRm00TCUGhYcZj TpQMhfYAi5LQjolnYmnz+/jetR/+obipzK9Rq4yk9iPkemX0aPQqHJMSY4KTNlniPFzy Gz1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=PmPqsk4Ds+rkfpu3nL2hTmPZ4zZI7ndI1Rv+jcAXn+g=; b=qLHGp5WZFGN/pEmf0K+ND30myi7xBIGB+7HbEa1QaFk7Q0AQdJWiEiZYr4y0Fa2d77 f3xIE3az8pP6QUj0gp8KRivy6MMMKlm6a3Cm7UZIr7jZBt8n2HJOsuOJNe8VebaE7GZe WpE6puCa745EQwx3SLqb7plHjYetX/mW0V8O83cch4Uu5vt/nlfgsFcSCv54OYBH+z1o 30XsTTdsM+EgxZPY5skHHE+DyC+teLnm3nw3PiicRZr3zAhELUZ6EppKqkorZimLFnWZ EyAXzsXOOidrH+Ti2pfQLaUq/2s1pjkBFw4kRHE3WQtW19JKWU1fmWBX2Q+Qc0voT/a+ PYyQ== X-Gm-Message-State: AOAM532vanpeW4x85PILUCbtBaClppwwxmQn0c2b4L7h3Ny3K9P3X8pY jTyIQtip2goLkuwQf0YciJeODw== X-Received: by 2002:a17:90b:4c88:b0:1dc:60c2:25b2 with SMTP id my8-20020a17090b4c8800b001dc60c225b2mr21748033pjb.133.1652016717528; Sun, 08 May 2022 06:31:57 -0700 (PDT) Received: from localhost ([139.177.225.234]) by smtp.gmail.com with ESMTPSA id cj25-20020a056a00299900b0050dc76281e1sm6590444pfb.187.2022.05.08.06.31.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 06:31:57 -0700 (PDT) Date: Sun, 8 May 2022 21:31:54 +0800 From: Muchun Song To: Baolin Wang Cc: akpm@linux-foundation.org, mike.kravetz@oracle.com, catalin.marinas@arm.com, will@kernel.org, tsbogend@alpha.franken.de, James.Bottomley@HansenPartnership.com, deller@gmx.de, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, borntraeger@linux.ibm.com, svens@linux.ibm.com, ysato@users.sourceforge.jp, dalias@libc.org, davem@davemloft.net, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v2 2/3] mm: rmap: Fix CONT-PTE/PMD size hugetlb issue when migration Message-ID: References: <1ec8a987be1a5400e077260a300d0079564b1472.1652002221.git.baolin.wang@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1ec8a987be1a5400e077260a300d0079564b1472.1652002221.git.baolin.wang@linux.alibaba.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Sun, May 08, 2022 at 05:36:40PM +0800, Baolin Wang wrote: > On some architectures (like ARM64), it can support CONT-PTE/PMD size > hugetlb, which means it can support not only PMD/PUD size hugetlb: > 2M and 1G, but also CONT-PTE/PMD size: 64K and 32M if a 4K page > size specified. > > When migrating a hugetlb page, we will get the relevant page table > entry by huge_pte_offset() only once to nuke it and remap it with > a migration pte entry. This is correct for PMD or PUD size hugetlb, > since they always contain only one pmd entry or pud entry in the > page table. > > However this is incorrect for CONT-PTE and CONT-PMD size hugetlb, > since they can contain several continuous pte or pmd entry with > same page table attributes. So we will nuke or remap only one pte > or pmd entry for this CONT-PTE/PMD size hugetlb page, which is > not expected for hugetlb migration. The problem is we can still > continue to modify the subpages' data of a hugetlb page during > migrating a hugetlb page, which can cause a serious data consistent > issue, since we did not nuke the page table entry and set a > migration pte for the subpages of a hugetlb page. > > To fix this issue, we should change to use huge_ptep_clear_flush() > to nuke a hugetlb page table, and remap it with set_huge_pte_at() > and set_huge_swap_pte_at() when migrating a hugetlb page, which > already considered the CONT-PTE or CONT-PMD size hugetlb. > > Signed-off-by: Baolin Wang This looks fine to me. Reviewed-by: Muchun Song Thanks.