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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A448C4332F for ; Fri, 21 Oct 2022 04:08:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 979F08E0002; Fri, 21 Oct 2022 00:08:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 92B378E0001; Fri, 21 Oct 2022 00:08:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7F2618E0002; Fri, 21 Oct 2022 00:08:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 6C2028E0001 for ; Fri, 21 Oct 2022 00:08:28 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 486CDA0209 for ; Fri, 21 Oct 2022 04:08:28 +0000 (UTC) X-FDA: 80043624696.10.3132DB0 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by imf07.hostedemail.com (Postfix) with ESMTP id B3A8C4000A for ; Fri, 21 Oct 2022 04:08:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666325307; x=1697861307; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=bf5sIebrRjerkXBiHhejNDTo9YDTgaUUT5P8ABmQ1vI=; b=F8dey4jpzhHlkg7xwjeF/Ph8V/AyfIqKwa+7ZjJKNd1wbWBhCnd6y5hy ln0HwuEVX5M2KSiAILq2NX3NI6aNR6E0ekLPQIxAfEl6JxpOZ4KTXQgE4 wbBScx2aBYmPZjKdchSzJJ0WNcOXjPpdOcn98kR7SNi/4HRfrdFQAI08C EtlvatoVry1xwWoHtMOnVeGAjCsm/yUTVYGKsDPJqvZFp+nJSaMCZUXDx TRfX1VBgRcDVsUCeTXgagRzgs7OJ3ARJjg0t8pJrIPeW818RL2wNZ8iiq K2+lsYMReKhMDy1Sx02uSIJYvPdGq4vSu7hQLIhbZ+oXS3ETHHuqyE/3q g==; X-IronPort-AV: E=McAfee;i="6500,9779,10506"; a="294302453" X-IronPort-AV: E=Sophos;i="5.95,200,1661842800"; d="scan'208";a="294302453" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2022 21:08:25 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10506"; a="735297385" X-IronPort-AV: E=Sophos;i="5.95,200,1661842800"; d="scan'208";a="735297385" Received: from agluck-desk3.sc.intel.com ([172.25.222.78]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2022 21:08:25 -0700 Date: Thu, 20 Oct 2022 21:08:24 -0700 From: Tony Luck To: Shuai Xue Cc: Naoya Horiguchi , Andrew Morton , Miaohe Lin , Matthew Wilcox , Dan Williams , Michael Ellerman , Nicholas Piggin , Christophe Leroy , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH v2] mm, hwpoison: Try to recover from copy-on write faults Message-ID: References: <20221019170835.155381-1-tony.luck@intel.com> <893b681b-726e-94e3-441e-4d68c767778a@linux.alibaba.com> <359bae4e-6ce3-cc7e-33d0-252064157bc6@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <359bae4e-6ce3-cc7e-33d0-252064157bc6@linux.alibaba.com> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666325308; a=rsa-sha256; cv=none; b=ZRnES7bEHfqr0KJlbQXGt6F4qxevR0eZWWq5KhgLr1A756V4+hdi/ApA5J88lRUjdNb8By 8ruLfTrjNtWS5eaelis5qh5UlCQoFUDUnp1YI4K43R5x90vNfB/GrySq9ko+1b/87pdUEK uqKF9Qn/cs8Xktg8vVPaB5C9iNdMp9c= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=F8dey4jp; spf=pass (imf07.hostedemail.com: domain of tony.luck@intel.com designates 134.134.136.20 as permitted sender) smtp.mailfrom=tony.luck@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666325308; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ACJzaqIOSUZ3ylYVG+omFtaQ72n0DbZu3a1Dd5RVSLI=; b=BJncYRtbM5Is8tlhaqxq3+iO7aeAo9u+k2zcxm+XkDbGR87Wg668/3RTakywxuUij65kUK zRSxTDqjs3wRVolK9mwfjQgOJuxxKqFiPf7mXLkjIZ2z1ZiZGBuNrPlWQltT++KtbU7KXa epCv+8KjNMrH+hOq58/J7kWD5jdLucI= X-Rspam-User: Authentication-Results: imf07.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=F8dey4jp; spf=pass (imf07.hostedemail.com: domain of tony.luck@intel.com designates 134.134.136.20 as permitted sender) smtp.mailfrom=tony.luck@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Stat-Signature: q63fjbs4e66ob3nj9eix9i4m5xdizei8 X-Rspamd-Queue-Id: B3A8C4000A X-Rspamd-Server: rspam10 X-HE-Tag: 1666325307-98114 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 Fri, Oct 21, 2022 at 09:52:01AM +0800, Shuai Xue wrote: > > > 在 2022/10/21 AM4:05, Tony Luck 写道: > > On Thu, Oct 20, 2022 at 09:57:04AM +0800, Shuai Xue wrote: > >> > >> > >> 在 2022/10/20 AM1:08, Tony Luck 写道: > > I'm experimenting with using sched_work() to handle the call to > > memory_failure() (echoing what the machine check handler does using > > task_work)_add() to avoid the same problem of not being able to directly > > call memory_failure()). > > Work queues permit work to be deferred outside of the interrupt context > into the kernel process context. If we return to user-space before the > queued memory_failure() work is processed, we will take the fault again, > as we discussed recently. > > commit 7f17b4a121d0d ACPI: APEI: Kick the memory_failure() queue for synchronous errors > commit 415fed694fe11 ACPI: APEI: do not add task_work to kernel thread to avoid memory leak > > So, in my opinion, we should add memory failure as a task work, like > do_machine_check does, e.g. > > queue_task_work(&m, msg, kill_me_maybe); Maybe ... but this case isn't pending back to a user instruction that is trying to READ the poison memory address. The task is just trying to WRITE to any address within the page. So this is much more like a patrol scrub error found asynchronously by the memory controller (in this case found asynchronously by the Linux page copy function). So I don't feel that it's really the responsibility of the current task. When we do return to user mode the task is going to be busy servicing a SIGBUS ... so shouldn't try to touch the poison page before the memory_failure() called by the worker thread cleans things up. > > + INIT_WORK(&p->work, do_sched_memory_failure); > > + p->pfn = pfn; > > + schedule_work(&p->work); > > +} > > I think there is already a function to do such work in mm/memory-failure.c. > > void memory_failure_queue(unsigned long pfn, int flags) Also pointed out by Miaohe Lin ... this does exacly what I want, and is working well in tests so far. So perhaps a cleaner solution than making the kill_me_maybe() function globally visible. -Tony