Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp724904pxf; Thu, 1 Apr 2021 11:52:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxL8GDx7d/42uf5WfutrNTPGwGaSEQS2b5n33Absn/d2arnq+MTgfdXQTsA7Z8wBLfI4t/o X-Received: by 2002:a92:7d11:: with SMTP id y17mr7793935ilc.93.1617303168767; Thu, 01 Apr 2021 11:52:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617303168; cv=none; d=google.com; s=arc-20160816; b=vOzPbE7DOjFKW6XgWahOPN4arkCFlUQhAAaOViVRX2JhNuVyCgdIkgiG00ypiWXs+F irG3gK1tsbmAK2HvITwB/paBdJClVI2EHnU+W00rJ8+fSVfaPUW8SQwkP9NVJbSAVak6 3mGUkyalF8ubriz+yw0JLG4BqywvgnztuMlzTLt0QnqrF5dAVzkNNgLXApNIB+AsAoz0 Nn1hixyLS5HMpPRlfcyB7D2i5sbTapVLh1pQ+3P0DiQ9u2B4+AnN12Fdv9eriHdayi7N 4/mvW+g4V9ZHu9gVw3sftZ/k/iy9JWx/xoLcJoRDDjDXDNtOYRTTMrj63l93LZ7q/Fvq Uv7w== 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:ironport-sdr :ironport-sdr; bh=RsqjUt1u2JahUUPuOJKnM6V6oSXiKZjlqIzCxjTjhIQ=; b=PgyRcrmwh2i06G8VFCNztg1c5NV8ON8qjddZAh7eydLdLTYjWBEu+bvjNBXdWYPm17 8l12Preznu+c+mVrIlzPUZTLnB1benEtiDpXmBxUeLQpvdouKoNynkUDWQutixA6kvjN q2P1/wvofeI/oqzgS6b1+QcmKSj7AC+0yi56THqSxs971Uh+eK976BZmlziWcBVD/2u0 YOUYjncMsjtwAypxw1VSz0SK6oJLUeh+exbhlkJP8ujF/owjUP6d/lVtty5CSFIEgkqW mAbWOIkRHlvuolEexgqbSnjYB/EQ8T9aJhMRxiBxiId1WgNUnVkZ7G/3RCE+e6fiO2eL yBpg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x18si6110055jas.18.2021.04.01.11.52.34; Thu, 01 Apr 2021 11:52:48 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240823AbhDASvr (ORCPT + 99 others); Thu, 1 Apr 2021 14:51:47 -0400 Received: from mga17.intel.com ([192.55.52.151]:21439 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239256AbhDASfj (ORCPT ); Thu, 1 Apr 2021 14:35:39 -0400 IronPort-SDR: Gf3Fn9b7pipnaxsjEv1Ah6uRe5TX1AYqGmxCFhydoJPIm0CPoesTCtBGWFLX9ZnaE8WDfHCCla zW6XbFAC9cng== X-IronPort-AV: E=McAfee;i="6000,8403,9941"; a="172299659" X-IronPort-AV: E=Sophos;i="5.81,296,1610438400"; d="scan'208";a="172299659" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2021 08:33:22 -0700 IronPort-SDR: EBPvS0zSWy2R1Xo9zIwtnmV8WneC4HY6sYw3cj6KTRVy6BNNiiIrGT6wSo3+56dBjtCXBklc7h zYcD1f4Y9sLg== X-IronPort-AV: E=Sophos;i="5.81,296,1610438400"; d="scan'208";a="419247613" Received: from agluck-desk2.sc.intel.com (HELO agluck-desk2.amr.corp.intel.com) ([10.3.52.146]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2021 08:33:22 -0700 Date: Thu, 1 Apr 2021 08:33:20 -0700 From: "Luck, Tony" To: Aili Yao Cc: HORIGUCHI =?utf-8?B?TkFPWUEo5aCA5Y+j44CA55u05LmfKQ==?= , Oscar Salvador , "david@redhat.com" , "akpm@linux-foundation.org" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "yangfeng1@kingsoft.com" , sunhao2@kingsoft.com Subject: Re: [PATCH v3] mm,hwpoison: return -EHWPOISON when page already poisoned Message-ID: <20210401153320.GA426964@agluck-desk2.amr.corp.intel.com> References: <20210305093656.6c262b19@alex-virtual-machine> <20210305221143.GA220893@agluck-desk2.amr.corp.intel.com> <20210308064558.GA3617@hori.linux.bs1.fc.nec.co.jp> <3690ece2101d428fb9067fcd2a423ff8@intel.com> <20210308223839.GA21886@hori.linux.bs1.fc.nec.co.jp> <20210308225504.GA233893@agluck-desk2.amr.corp.intel.com> <20210309100421.3d09b6b1@alex-virtual-machine> <20210309060440.GA29668@hori.linux.bs1.fc.nec.co.jp> <20210309143534.6c1a8ec5@alex-virtual-machine> <20210331192540.2141052f@alex-virtual-machine> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210331192540.2141052f@alex-virtual-machine> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 31, 2021 at 07:25:40PM +0800, Aili Yao wrote: > When the page is already poisoned, another memory_failure() call in the > same page now return 0, meaning OK. For nested memory mce handling, this > behavior may lead to one mce looping, Example: > > 1.When LCME is enabled, and there are two processes A && B running on > different core X && Y separately, which will access one same page, then > the page corrupted when process A access it, a MCE will be rasied to > core X and the error process is just underway. > > 2.Then B access the page and trigger another MCE to core Y, it will also > do error process, it will see TestSetPageHWPoison be true, and 0 is > returned. > > 3.The kill_me_maybe will check the return: > > 1244 static void kill_me_maybe(struct callback_head *cb) > 1245 { > > 1254 if (!memory_failure(p->mce_addr >> PAGE_SHIFT, flags) && > 1255 !(p->mce_kflags & MCE_IN_KERNEL_COPYIN)) { > 1256 set_mce_nospec(p->mce_addr >> PAGE_SHIFT, > p->mce_whole_page); > 1257 sync_core(); > 1258 return; > 1259 } > > 1267 } With your change memory_failure() will return -EHWPOISON for the second task that consumes poison ... so that "if" statement won't be true and so we fall into the following code: 1273 if (p->mce_vaddr != (void __user *)-1l) { 1274 force_sig_mceerr(BUS_MCEERR_AR, p->mce_vaddr, PAGE_SHIFT); 1275 } else { 1276 pr_err("Memory error not recovered"); 1277 kill_me_now(cb); 1278 } If this was a copy_from_user() machine check, p->mce_vaddr is set and the task gets a BUS_MCEERR_AR SIGBUS, otherwise we print that "Memory error not recovered" message and send a generic SIGBUS. I don't think either of those options is right. Combined with my "mutex" patch (to get rid of races where 2nd process returns early, but first process is still looking for mappings to unmap and tasks to signal) this patch moves forward a bit. But I think it needs an additional change here in kill_me_maybe() to just "return" if there is a EHWPOISON return from memory_failure() -Tony