Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2185076rwi; Fri, 21 Oct 2022 00:19:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7jdwThGBEQeT2YwoOYSKTGOIjLBHKC8xiGsp4rLuKxzOEUlbanbio1FjZYL6pxgjZRhjhK X-Received: by 2002:a05:6402:90a:b0:458:ca4d:a2f8 with SMTP id g10-20020a056402090a00b00458ca4da2f8mr16037565edz.230.1666336787133; Fri, 21 Oct 2022 00:19:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666336787; cv=none; d=google.com; s=arc-20160816; b=T0Gh7AwxmX8IpxRr3viQqUnjwg1OZ4W0UD0IINr3CsTVfwuuexL9c5q0Msc81VktcG poXlAQcWVeK5BMfqP5oh12QpSMJJDfWpqwBVA2Ljc4xjBegldq+lXP9v4NGMyUYstDVg w8HVTrZlOiXQ6akBP/lIMc5JZX3dTbqoxGa8oO4TE++j+UR9FKR4UOLodk+pyETCWb0w whqqM07f9CrtNC8bdTu6rNTaQ95PNVhlcLTVh6Y+908KQly6pqnuRPe5vpebxH3ZXCgL HAXMkpMcDumrZ4w2awDmW/Ocjfs0Cbj0ueK4hYe6ENXD+Xsj6Hok6wwGyPuS2kctQ8Xq klYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=JscbD3lW3+c9l+XWKZ+yB+aQ3PXNxwFEqTdu6UyDB2M=; b=jztYztvLspPwIeE74++NdSSnfmrtKIaVpRHsTXR1qGtZrBv8pLfI31XNngs8klp2bb NEpguZZN+az7t7BephwtXDKshbmvKES0Vp8O5z0u+UyrAUhTCyWQwovep1X5ZGIr9D3X UMM7/W9P0EVTYx4UGPQt90tYO2ScsUpm6o6gp452f9j8caPQOp4r451C9vOYuKzYMCHc jRGieecpWmnnfdjRymdtv/SEcjXJA5hUos5zGe1M4mBfnS+++HPzGPBXlUX38pYfFVV0 lIv0rEKABx/QqJU7io8BuZ1+8d/Oe/OwtOhQa2YBP7UfcQVZ8X0ziut2ub570tYvkH/E q19Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gm1-20020a1709073d0100b0073da19d0cdasi6385018ejc.973.2022.10.21.00.19.20; Fri, 21 Oct 2022 00:19:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229782AbiJUG5k (ORCPT + 99 others); Fri, 21 Oct 2022 02:57:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230158AbiJUG5g (ORCPT ); Fri, 21 Oct 2022 02:57:36 -0400 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32740244708 for ; Thu, 20 Oct 2022 23:57:34 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=xueshuai@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0VSiKiEG_1666335448; Received: from 30.32.67.117(mailfrom:xueshuai@linux.alibaba.com fp:SMTPD_---0VSiKiEG_1666335448) by smtp.aliyun-inc.com; Fri, 21 Oct 2022 14:57:29 +0800 Message-ID: Date: Fri, 21 Oct 2022 14:57:26 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Subject: Re: [PATCH v2] mm, hwpoison: Try to recover from copy-on write faults Content-Language: en-US To: Tony Luck 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 References: <20221019170835.155381-1-tony.luck@intel.com> <893b681b-726e-94e3-441e-4d68c767778a@linux.alibaba.com> <359bae4e-6ce3-cc7e-33d0-252064157bc6@linux.alibaba.com> From: Shuai Xue In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2022/10/21 PM12:08, Tony Luck 写道: > 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. Aha, I see the difference. Thank you. But I still have a question on this. Let us discuss in your reply to David Laight. Best Regards, Shuai > > 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