Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp535249pxk; Thu, 3 Sep 2020 06:29:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAJOplPHYYaHXHkNVE83ouRKYlYL7z8ux0CTWNyFCWGLxgxbke7danQwntogqqiuBNczjE X-Received: by 2002:a05:6402:220d:: with SMTP id cq13mr3054792edb.260.1599139747502; Thu, 03 Sep 2020 06:29:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599139747; cv=none; d=google.com; s=arc-20160816; b=MS72ATweNPBs8/4DUPJFb8RWIRPE/AQj6xRrvIepngPJ08QL7zzJK4AOH3pRNNU0q3 TWim82KDugguCTaEcHcvD1cgnRtikEIHBJkrJxCGyBRyUqbPjEmM9R1pLDQ31PAAiJCT /CIijYJHB9+w4UYKBiKmAw0kqB2JSaX2OP3F6m2rAfrzUj7NhHgzwho64gk147JGjJGT xxYFl4E8IlPU/q31I949xV72XqFORARJ2BWBT/2r2Z5+Rgit/xKIR08gsmZgJLLMx9KA iWMCSYpUXVTev7s5aVtBPEIYPtMuQF/dMSUCeM6+FOzyS3+ba22nZkuhmhWYAQp/Y/6+ Fa1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=onLl8rTDQyvNpKgJJE9dFmq94UrkQmRn/zbTPNdul+w=; b=DkGHoRGADPhWDdxmZaHynKZKZWE3L1MM4iCJsVfhe3QN8R2wrQEbN9zZX8PlqgszYl KXdS6yYm95vSTQAMba8Kinv5veYCgA8RQHryZIwgtAKBTd+R0vveXwB9jEliaJSNTIG9 w/8os0uo56adFDCOZ0Yy+XfLjcHw2fdDqgRUjOp7KfvK8NV1ylINjH2NDWUMEg0RrVdA lK19Ew/cUDeTcm2/uBOe4jsv6TGw773CtjZ+uIs/CdCXWYyM8Xln5RgUTw+a5NrZc0KK kjdG621yg8e/KggMSDTG9OIj3qpHMHtiRNhhz6IU+Q5StJJ5e3pRnWwlPmoJPP99Pesk WAgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=kyWZd6uS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f2si482413edn.26.2020.09.03.06.28.43; Thu, 03 Sep 2020 06:29:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=kyWZd6uS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729020AbgICNPa (ORCPT + 99 others); Thu, 3 Sep 2020 09:15:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728874AbgICMyn (ORCPT ); Thu, 3 Sep 2020 08:54:43 -0400 Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42DC8C061244 for ; Thu, 3 Sep 2020 05:54:43 -0700 (PDT) Received: by mail-lf1-x144.google.com with SMTP id m5so935685lfp.7 for ; Thu, 03 Sep 2020 05:54:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=onLl8rTDQyvNpKgJJE9dFmq94UrkQmRn/zbTPNdul+w=; b=kyWZd6uSWtnkPJPjNC9/5GmYksI/3zvd739yEGMNVYRRPQ+obtq6kc0P1lySF1wLna /9pVxkncaXRcO2tuJq3pvnexLY4/WEYs6tUJiejalUKE87aVDxTtE8HGZioi56/HtvGW yphbM/vIdOQS1E8H5tT9vqdWIBrlZSJthYKw99V3Br+Jb4Wy1/Z14Ngc4JlLjaNb+iBN xdzS5/4L9tad8h/PIo9T2VsXCmgBMNtPZPjyG+MR2avtJUVy/CwEcgRJqvxxJyZ5cc+b kVEFsNzOzEK2uw81sjvtX00wvqAEmpeahxzGvmJf2FDEtGdxJK92HT48bXtJyIME/kON QHxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=onLl8rTDQyvNpKgJJE9dFmq94UrkQmRn/zbTPNdul+w=; b=uavog567IatFqpcP/oXG3VYq8YXiNYAypEBZb6X44YQrizrWeah7+MIHL8on2In4aC c9Athof+pJzdvn/T/1GyChYRjIGcYiLqO5Rk02DNE4Xq+XtDreD3LHNAtPtFPedRag2y Jvcu6DpX8k9rKtLUF3UwPC2mXSwGFazOi1hhOQkT0GA/xNIFB24rF8VZcuiyffqES4s1 t8HZBDF6u5DSoVo8jLO5WJ94N812L2bCmhDEr+7JZteuy1+KTEjCrdwAWMCYzhprRjEe 1nwCMg9fyIXMx5hZzBP3An8RuxQ5c5kuny6USejp1wRdzTGYtKBLSrX6NsAWPGXe8J78 xLDQ== X-Gm-Message-State: AOAM531ipbrGAwbaEZ+cMimhYFy2ZpNdXrWIqkTbOUThPJerexpgcsnf wa0ZcgdaDIHCKDbYZRW6JQkw0g== X-Received: by 2002:a19:40c8:: with SMTP id n191mr1267052lfa.29.1599137681414; Thu, 03 Sep 2020 05:54:41 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id l16sm595692ljb.72.2020.09.03.05.54.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 05:54:40 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id 321BC102212; Thu, 3 Sep 2020 15:54:42 +0300 (+03) Date: Thu, 3 Sep 2020 15:54:42 +0300 From: "Kirill A. Shutemov" To: Ralph Campbell Cc: linux-mm@kvack.org, nouveau@lists.freedesktop.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Jerome Glisse , John Hubbard , Alistair Popple , Christoph Hellwig , Jason Gunthorpe , Bharata B Rao , Ben Skeggs , Shuah Khan , Andrew Morton Subject: Re: [PATCH v2 1/7] mm/thp: fix __split_huge_pmd_locked() for migration PMD Message-ID: <20200903125442.4no5dq7mzcdllery@box> References: <20200902165830.5367-1-rcampbell@nvidia.com> <20200902165830.5367-2-rcampbell@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200902165830.5367-2-rcampbell@nvidia.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 02, 2020 at 09:58:24AM -0700, Ralph Campbell wrote: > A migrating transparent huge page has to already be unmapped. Otherwise, > the page could be modified while it is being copied to a new page and > data could be lost. The function __split_huge_pmd() checks for a PMD > migration entry before calling __split_huge_pmd_locked() leading one to > think that __split_huge_pmd_locked() can handle splitting a migrating PMD. > However, the code always increments the page->_mapcount and adjusts the > memory control group accounting assuming the page is mapped. > Also, if the PMD entry is a migration PMD entry, the call to > is_huge_zero_pmd(*pmd) is incorrect because it calls pmd_pfn(pmd) instead > of migration_entry_to_pfn(pmd_to_swp_entry(pmd)). > Fix these problems by checking for a PMD migration entry. > > Signed-off-by: Ralph Campbell Hm. Could you remind me what codepath splits migration PMD? Maybe it should wait until migration is complete? We could avoid a lot of complexity this way. -- Kirill A. Shutemov