Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1025646pxu; Thu, 8 Oct 2020 00:57:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYLdQ0/hlfE8ktvKseQpHB7zFNxcbwWQQVq9hJlRIKee3v0CC6SCOjlVBg/nyb3GGggMyo X-Received: by 2002:aa7:dc16:: with SMTP id b22mr7625571edu.252.1602143864285; Thu, 08 Oct 2020 00:57:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602143864; cv=none; d=google.com; s=arc-20160816; b=mmxu/CCMMrnjrVG5N86GnGXkFqyeQkMD4fSRadAv/btRqWTxTdEcJpnrWNDHIj7GQx KcZd63kj+6nUuVV28GWgpiCY9Gu74eGSfh76QoL+908BXdcn+tWydwc3GQtltj7EvLRX l6SdVqahRbxXHWKvD0G1CWGqVIIurbZsAmOVOYegPdsfkrTVsbrteYPKr7BRHpQkppB5 1uJ3xRqnm2dSlrUMm53oX78imqZ2R7uhWv/tO794zQBsYhXfa63zoPqNtHEchrS8byg/ HdgaCRlk0G89IJSrNoKU/HF7okdlPouldQGMwcO1BmKhjvr89htNIMoockmLHGjQnIg4 Ylxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=IEHhXQUdY1ZNSJ6cw3hAQj1j8oPXbE4ltFHOuzAEm/k=; b=DNZxqha2bxI29c7j35XPtbsPPBaRPIcC5QfwYaFuY/7D6dSlNK7I6gJIs5YbPs6loQ 8HPXq1MBFrekqrG/0w4zguTNs5Y5eF8UuBGsIZN75V4BcTZvZaS9j1QKAl5k94Kq264s 9pi6D9qd7iQKXz8ZOx0AN6TrVqqkK8r2I7iCeMKmmaUFuVOJY0i4POOstdbVaoLKwwVs DIbEyFSLxoVIgCEm0VfJfeP3w6YZ040GDUiMBc9GsMXZcmPIWZNKXtfwmtM6i9v9uAu+ NcnsDO3K6QXLIBPt7uQJGIiZie8c9TGcinteI6UBlihkYJ1yFRSecPxazhNSiB4HD1SH OrPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NYkyGdYY; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a24si3104460ejs.437.2020.10.08.00.57.21; Thu, 08 Oct 2020 00:57:44 -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=@gmail.com header.s=20161025 header.b=NYkyGdYY; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728876AbgJHHzC (ORCPT + 99 others); Thu, 8 Oct 2020 03:55:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728838AbgJHHyt (ORCPT ); Thu, 8 Oct 2020 03:54:49 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 955BFC0613D3; Thu, 8 Oct 2020 00:54:49 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id x22so3296584pfo.12; Thu, 08 Oct 2020 00:54:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=IEHhXQUdY1ZNSJ6cw3hAQj1j8oPXbE4ltFHOuzAEm/k=; b=NYkyGdYYBu2sahdkP3l459Nd8euDPH28LupNgJ0OWQcTZQwjp/PhiM/4h1TJ5gx3gq b41NeP0TNtOBG5zqIdShwail8eMLCKNazBvRAPChNLIBefQyGiguYt0zP3kD3PGdXC5e gnUbY82y+GsG7YD/z91+bF/ZrBRE2twZmTBpIJzcUzaf4kG+9QCL3Ng8+SKLwLrknZ6b KMyAB901/+dVpdYMDm0f/UyxXCABztevhmhXbJeu41BjyzipwOvZWHmfHqVW9wkd+tCe 2BLv9OLJO4RF7vReMUHxtZjapseku4xEx6hI/gO7ruPwQlmZ5pgIwTRffBJ0ZIb9qYqz dq+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=IEHhXQUdY1ZNSJ6cw3hAQj1j8oPXbE4ltFHOuzAEm/k=; b=hoeL3g2tTHGVW+qQ1suhWO4J7pzmV12k6cKCmsothBuVbKM3RTcBVv6wrqZhq/O0qT L/JSD7EbvBZtWMppp6CMdst1OiD5/RQbiZHUzzLC/qUJhmBfFIoHLo9U/dZJDANbj4JJ +mv/0m9KC3dFycXv9CaONx9cE9MOhZpRuyqSUceuuNEtiXP6AfCz4FpgAbsAMeJDG/z0 MQVHvSw0+WQjKfkEsXyulvkEKkYDpasrRF+NBiAhXhLBRALZq3z00fLrAEy/5J6uDrIB mKI0sKfZZGfU6s+zAjTBH4kPoJhlj8qKI83VqQ/fSsVgj410n8LaWjXt6BOjLet8jvq/ MDhQ== X-Gm-Message-State: AOAM5308i2ZUCEGvF2GluypuW4Xn6y90LioegmdYA/XVFwp19SdcC39w brBlzCmWZFWvcg4LDJsyWwc= X-Received: by 2002:a17:90a:cf8b:: with SMTP id i11mr7006668pju.181.1602143689231; Thu, 08 Oct 2020 00:54:49 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.61]) by smtp.gmail.com with ESMTPSA id k206sm6777106pfd.126.2020.10.08.00.54.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Oct 2020 00:54:48 -0700 (PDT) From: yulei.kernel@gmail.com X-Google-Original-From: yuleixzhang@tencent.com To: akpm@linux-foundation.org, naoya.horiguchi@nec.com, viro@zeniv.linux.org.uk, pbonzini@redhat.com Cc: linux-fsdevel@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, xiaoguangrong.eric@gmail.com, kernellwp@gmail.com, lihaiwei.kernel@gmail.com, Yulei Zhang , Chen Zhuo Subject: [PATCH 14/35] mm, dmem: dmem-pmd vs thp-pmd Date: Thu, 8 Oct 2020 15:54:04 +0800 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yulei Zhang A dmem huge page is ultimately not a transparent huge page. As we decided to use pmd_special() to distinguish dmem-pmd from thp-pmd, we should make some slightly different semantics between pmd_special() and pmd_trans_huge(), just as pmd_devmap() in upstream. This distinction is especially important in some mm-core paths such as zap_pmd_range(). Explicitly mark the pmd_trans_huge() helpers that dmem needs by adding pmd_special() checks. This method could be reused in many mm-core paths. Signed-off-by: Chen Zhuo Signed-off-by: Yulei Zhang --- arch/x86/include/asm/pgtable.h | 10 +++++++++- include/linux/pgtable.h | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index ea4554a728bc..e29601cad384 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -260,7 +260,7 @@ static inline int pmd_large(pmd_t pte) /* NOTE: when predicate huge page, consider also pmd_devmap, or use pmd_large */ static inline int pmd_trans_huge(pmd_t pmd) { - return (pmd_val(pmd) & (_PAGE_PSE|_PAGE_DEVMAP)) == _PAGE_PSE; + return (pmd_val(pmd) & (_PAGE_PSE|_PAGE_DEVMAP|_PAGE_DMEM)) == _PAGE_PSE; } #ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD @@ -276,6 +276,14 @@ static inline int has_transparent_hugepage(void) return boot_cpu_has(X86_FEATURE_PSE); } +#ifdef CONFIG_ARCH_HAS_PTE_DMEM +static inline int pmd_special(pmd_t pmd) +{ + return (pmd_val(pmd) & (_PAGE_SPECIAL | _PAGE_DMEM)) == + (_PAGE_SPECIAL | _PAGE_DMEM); +} +#endif + #ifdef CONFIG_ARCH_HAS_PTE_DEVMAP static inline int pmd_devmap(pmd_t pmd) { diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index 45d4c4a3e519..1fe8546c0a7c 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -1134,6 +1134,11 @@ static inline pmd_t pmd_mkdmem(pmd_t pmd) { return pmd; } + +static inline int pmd_special(pmd_t pmd) +{ + return 0; +} #endif #ifndef pmd_read_atomic -- 2.28.0