Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1763929rwl; Thu, 30 Mar 2023 00:53:31 -0700 (PDT) X-Google-Smtp-Source: AKy350aQrYgW+16R8ZBKq27+GcI/Ki/IYwQVLfvEUoZU+9tK+1oFJme8yfbQNDFPesgm3vhmyvku X-Received: by 2002:a17:906:74c3:b0:933:fa42:7e36 with SMTP id z3-20020a17090674c300b00933fa427e36mr1166017ejl.5.1680162811529; Thu, 30 Mar 2023 00:53:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680162811; cv=none; d=google.com; s=arc-20160816; b=wtb6cWKfx0Rmu2Kyb0YvDPJ01xIHrn2RG2sTmi8EiUenMKR+B061gfHiF1yd0Vaxdi pTQoc60o3SpTjKiffrqFpvXdvUqK2eRKFiWWzKkMKMpeVFHzsvmLV78zx4kj9oyPJvwW MhAr7iV0hXBZa49l0ekwmj+Fg5dxtBsTttLHEp5wEg1swtBp7ZKGLsieooHL2HV6oVSO O7j3iV9s060L2aAfIA2B1ltGVPRvArtKhzzx4e5SFyrCXvo/I8x7nFeXeljRcsuhUZpH MGQ8IYnYisjSiCKdmjQb3p/1721zI0sjITNxhPCPXp7ulwjPOYs/igCrsKkB0pYh/7IV Wv1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=dPR0hfq50PijXhsLX33GK6ckIrfxZlDJUmLfcEdL5Xg=; b=zE3+emDKat/Q5tlZkiGdehNT8Iv+GHffBQqRlzKIst90XcyXIZ5vm68jvxR3oY2HHv T9Qpm/fS5YmFrLM0RSrAgAhUeQf6lMNJ45JqlzIvHeQwB/cEXtRKialr5+OIoh7yJOb3 0V58ZO5ZiOc38xZV6n9zyAhqb5VfQDfzTVx8sBEoSbCulZXlGchlvtNNUJV8P5OZh+a7 x1JZpD8N7oWzMS7QwZcZfwyL3JG8n+XhZk4N3Iu97rb9yzMws5FytZVTeCGesOmRg43N CGeP5X4lTfimBx3Bj5pmEN7pWzZ6DPLdCtMMxZk0TwLT5mx13xOHJCOEQlghGRQog4Yx qgkw== 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ke27-20020a17090798fb00b008b1785971dcsi35217876ejc.630.2023.03.30.00.53.06; Thu, 30 Mar 2023 00:53:31 -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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229616AbjC3Hpo (ORCPT + 99 others); Thu, 30 Mar 2023 03:45:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229608AbjC3Hpm (ORCPT ); Thu, 30 Mar 2023 03:45:42 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAE411721 for ; Thu, 30 Mar 2023 00:45:41 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4PnFmt2LgdzrZDC; Thu, 30 Mar 2023 15:44:30 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by kwepemm600003.china.huawei.com (7.193.23.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 30 Mar 2023 15:45:39 +0800 From: Longlong Xia To: , CC: , , , , , Longlong Xia Subject: [PATCH 0/2] mm: ksm: support hwpoison for ksm page Date: Thu, 30 Mar 2023 15:44:59 +0800 Message-ID: <20230330074501.205092-1-xialonglong1@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm600003.china.huawei.com (7.193.23.202) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 Currently, ksm does not support hwpoison. As ksm is being used more widely for deduplication at the system level, container level, and process level, supporting hwpoison for ksm has become increasingly important. However, ksm pages were not processed by hwpoison in 2009 [1]. The main method of implementation: 1. Refactor add_to_kill() and add new add_to_kill_*() to better accommodate the handling of different types of pages. 2. Add collect_procs_ksm() to collect processes when the error hit an ksm page. 3. Add task_in_to_kill_list() to avoid duplicate addition of tsk to the to_kill list. 4. Try_to_unmap ksm page (already supported). 5. Handle related processes such as sending SIGBUS. Tested with poisoning to ksm page from 1) different process 2) one process and with/without memory_failure_early_kill set, the processes are killed as expected with the patchset. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/ commit/?h=01e00f880ca700376e1845cf7a2524ebe68e47d6 Longlong Xia (2): mm: memory-failure: Refactor add_to_kill() mm: ksm: Support hwpoison for ksm page include/linux/ksm.h | 11 ++++++++ include/linux/mm.h | 7 +++++ mm/ksm.c | 45 ++++++++++++++++++++++++++++++++ mm/memory-failure.c | 63 +++++++++++++++++++++++++++++++++------------ 4 files changed, 109 insertions(+), 17 deletions(-) -- 2.25.1