Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp106563ybl; Thu, 9 Jan 2020 17:57:08 -0800 (PST) X-Google-Smtp-Source: APXvYqwVq5en0S/CIp4vPlCKgF7ywhlXywzW6BoPWvbaiSHmwpdoazf7+lx1XwLqIs4r87Rcvrvh X-Received: by 2002:a9d:5885:: with SMTP id x5mr679027otg.132.1578621428854; Thu, 09 Jan 2020 17:57:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578621428; cv=none; d=google.com; s=arc-20160816; b=DNfBGSEE0x762Ub4ekm4B8dJzQRCgh0gOVuTCutAwDgvf004bNoJKkX033HVNki2rI ScFS/Bpe0KZi6hM7HxuJga43Sr9vpoz49AnvjTwDX+Ze05pzCT5LXmyldbleo6ZksQFF rkEoozAJjYorxY+eJmjqveuIDUEEHHN+VhkbPeY45IrK7NXUb0yVSG9heiRlSZHntbNV PrU1S7boeZsR0PrHNrTjvuWHy2zqbYmwYmG/ap55QXIxBOmFkxuE+t2xCVBjRWGzOazu rUiaBk+PkjRHEAg81Lv6pnGsYs7EIMCRfwQ7gM7Ttwa3WKHMJMF/f1kmobSFCYTuPbEJ rtQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date; bh=W9lTu45ZvjAZ5D94XIjYPf1E9mC6z1H9prkLZIb3wzY=; b=p9vzdhmlEXWjLc+ic1ZkUpFKE+AG6IM7S/WZBoR+qQ0TR5cMzDFU68c/iUkkiDjqj1 /kHI9wSqmMbPHForPPp8wbH+XAiv29sgnvFgH4C4gkePxfeqF+nspCRCsz0E+TxC88tx yts6A1s/dSKopHEQmsmaIRf2LN0SDNLVJdp0e1BeVu/uKkujmYdOLvS7cZf8yROzAXQU 4X/y/v0S8XIG3lWWRzBdhtt5OeVyk8GCB5ZtlHG3pFf6Z15FA1HE1n+T0nAxqFRo03MR WudJxiOXMCGIT4+skP19LvlotWnRgNA9c0fgBr/x1g4P18Taw2lFvHfrsZoyVsqTib3b 0K2w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l16si257401otj.59.2020.01.09.17.56.57; Thu, 09 Jan 2020 17:57:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730625AbgAJBzw (ORCPT + 99 others); Thu, 9 Jan 2020 20:55:52 -0500 Received: from mga07.intel.com ([134.134.136.100]:49142 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730359AbgAJBzv (ORCPT ); Thu, 9 Jan 2020 20:55:51 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jan 2020 17:55:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,414,1571727600"; d="scan'208";a="246855115" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga004.fm.intel.com with ESMTP; 09 Jan 2020 17:55:49 -0800 Date: Fri, 10 Jan 2020 09:55:48 +0800 From: Wei Yang To: "Kirill A. Shutemov" Cc: Wei Yang , akpm@linux-foundation.org, kirill.shutemov@linux.intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, richard.weiyang@gmail.com Subject: Re: [RFC PATCH] mm/rmap.c: finer hwpoison granularity for PTE-mapped THP Message-ID: <20200110015548.GA16823@richard> Reply-To: Wei Yang References: <20200102030421.30799-1-richardw.yang@linux.intel.com> <20200109123233.ye2h4dxaubu4ad22@box> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200109123233.ye2h4dxaubu4ad22@box> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 09, 2020 at 03:32:33PM +0300, Kirill A. Shutemov wrote: >On Thu, Jan 02, 2020 at 11:04:21AM +0800, Wei Yang wrote: >> Currently we behave differently between PMD-mapped THP and PTE-mapped >> THP on memory_failure. >> >> User detected difference: >> >> For PTE-mapped THP, the whole 2M range will trigger MCE after >> memory_failure(), while only 4K range for PMD-mapped THP will. >> >> Direct reason: >> >> All the 512 PTE entry will be marked as hwpoison entry for a PTE-mapped >> THP while only one PTE will be marked for a PMD-mapped THP. >> >> Root reason: >> >> The root cause is PTE-mapped page doesn't need to split pmd which skip >> the SPLIT_FREEZE process. > >I don't follow how SPLIT_FREEZE is related to pisoning. Cold you >laraborate? > Sure. Let me try to explain this a little. split_huge_page_to_list unmap_page try_to_unmap_one ... __split_huge_pmd_locked __split_huge_page remap_page There are two dimensions: * PMD mapped THP and PTE mapped THP * HWPOISON-ed page and non-HWPOISON-ed page So there are total 4 cases. 1. First let's take a look at the normal case, when HWPOISON is not set. If the page is PMD-mapped, SPLIT_FREEZE is passed down in flags. And finally passed to __split_huge_pmd_locked. In this function, when freeze is true, PTE will be set to migration entry. And because __split_huge_pmd_locked save migration entry to PTE, try_to_unmap_one will not do real unmap. Then remap_page restore those migration entry back. If the page is PTE-mapped, __split_huge_pmd_locked will be skipped since this is already done. This means try_to_unmap_one will do the real unmap. Because SPLIT_FREEZE is passed, PTE will be set to migration entry, which is the same behavior as PMD-mapped page. Then remap_page restore those migration entry back. This shows PMD-mapped and PTE-mapped page share the same result on split. While difference is who sets PTE as migration entry * __split_huge_pmd_locked does this job for PMD-mapped page * try_to_unmap_one does this job for PTE-mapped page 2. Now let's take a look at the HWPOISON case. There are two critical differences * __split_huge_pmd_locked is skipped for PTE-mapped page * HWPOISON effects the behavior of try_to_unmap_one Then for PMD-mapped page, HWPOISON has no effect on split. But for PTE-mapped page, all PTE will be set to hwpoison entry. Then in memory_failure, the page split will have two different PTE result. Not sure I explain it clearly. -- Wei Yang Help you, Help me