From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC04FC33CA1 for ; Fri, 10 Jan 2020 01:55:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8B7222072E for ; Fri, 10 Jan 2020 01:55:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8B7222072E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1B4CD8E0005; Thu, 9 Jan 2020 20:55:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 13DCF8E0001; Thu, 9 Jan 2020 20:55:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F1FCC8E0005; Thu, 9 Jan 2020 20:55:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0113.hostedemail.com [216.40.44.113]) by kanga.kvack.org (Postfix) with ESMTP id D4FCC8E0001 for ; Thu, 9 Jan 2020 20:55:53 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 9005C181AC9CB for ; Fri, 10 Jan 2020 01:55:53 +0000 (UTC) X-FDA: 76360058586.01.lip16_335c0572efd11 X-HE-Tag: lip16_335c0572efd11 X-Filterd-Recvd-Size: 4105 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by imf26.hostedemail.com (Postfix) with ESMTP for ; Fri, 10 Jan 2020 01:55:52 +0000 (UTC) X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jan 2020 17:55:50 -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) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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