Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6814327pxv; Fri, 30 Jul 2021 03:05:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEokobnNB7jGBXcdPDSRARWNpDmIPIlOCsTYvc4xVjaPBqT2Zk24+PUedEwqeRBipaoswA X-Received: by 2002:a17:906:af7c:: with SMTP id os28mr1786060ejb.341.1627639559220; Fri, 30 Jul 2021 03:05:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627639559; cv=none; d=google.com; s=arc-20160816; b=CC4uWPYi13mturp0M11s1Qor1G0wC4GXygLBHNxC07m+O2J2dKJkY3ZDBHiq3O9gw9 6VoMJDeCYKO2HbDdS1sgfv+icBentEPhXEGCMiSKuRk9EPQcXcMU+6paboWcFlj50s43 3/AucostPTkM/IubZ9KLd1AztYp6uZVglMIE1auivF2an0G5dN5kMFVuvrmyLBZRYebJ dw6hrha0Crq39ZGxSlvaDgCyw9xi1fD+dzYtPMMPQ5WMUjSKVPNj9X7jm21TWjUT8HJ4 q1UQKrL5b7/poNbi2clWH1FgGVkl2XgASas7eA/z130oUhl27H5Rq4RgJX1w5tSZrIP5 n/YQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-hdrordr; bh=VVE33Kg3Un9GQSjHk2abwy7wv9/bD7IlL2oNBoIDzK0=; b=fRBIie5QbXzsezEDXXj9BFtHxjkv6+EbLHuKArDHC7ARfrWLHijxMrZhACT5sWzv7A giXky7h82RRb53lmKlhxQKvKOX/tcf4Z1G1QBQoJcZv+c6u7IMhrhroJ0Ue75VUHlN7k uzi1X6zYYWb+GHWehiNXfha946uZ4PrAu5khzDGqXkdaoiBGe3UHJd+JGekJDCI0bNOy hdDCHsdPwnh1cbpb/QeHu0d1McAtQdBiIZGgSgK4qFA/nR55VsbfgkzK49Bgq8JvmNN3 z2kbN0UxgTOF2lWcQt5tMrj8EPod4hGhUrxUOmx+XxWZNx0uTx4bwSGJSUchckhyl63k QnUQ== 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=fujitsu.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id de42si1107475ejc.471.2021.07.30.03.05.19; Fri, 30 Jul 2021 03:05:59 -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=fujitsu.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238384AbhG3KD6 (ORCPT + 99 others); Fri, 30 Jul 2021 06:03:58 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:36456 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238365AbhG3KCT (ORCPT ); Fri, 30 Jul 2021 06:02:19 -0400 IronPort-HdrOrdr: =?us-ascii?q?A9a23=3AE1WGoqww46PMIhwpzIqSKrPwEL1zdoMgy1kn?= =?us-ascii?q?xilNoH1uA6ilfqWV8cjzuiWbtN9vYhsdcLy7WZVoIkmskKKdg7NhXotKNTOO0A?= =?us-ascii?q?SVxepZnOnfKlPbexHWx6p00KdMV+xEAsTsMF4St63HyTj9P9E+4NTvysyVuds?= =?us-ascii?q?=3D?= X-IronPort-AV: E=Sophos;i="5.84,281,1620662400"; d="scan'208";a="112074008" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 30 Jul 2021 18:02:12 +0800 Received: from G08CNEXMBPEKD06.g08.fujitsu.local (unknown [10.167.33.206]) by cn.fujitsu.com (Postfix) with ESMTP id 39DD64D0D4A2; Fri, 30 Jul 2021 18:02:12 +0800 (CST) Received: from G08CNEXJMPEKD02.g08.fujitsu.local (10.167.33.202) by G08CNEXMBPEKD06.g08.fujitsu.local (10.167.33.206) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Fri, 30 Jul 2021 18:02:11 +0800 Received: from G08CNEXCHPEKD09.g08.fujitsu.local (10.167.33.85) by G08CNEXJMPEKD02.g08.fujitsu.local (10.167.33.202) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Fri, 30 Jul 2021 18:02:12 +0800 Received: from irides.mr.mr.mr (10.167.225.141) by G08CNEXCHPEKD09.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.23 via Frontend Transport; Fri, 30 Jul 2021 18:02:10 +0800 From: Shiyang Ruan To: , , , , , CC: , , , , , Subject: [PATCH RESEND v6 4/9] pmem,mm: Implement ->memory_failure in pmem driver Date: Fri, 30 Jul 2021 18:01:53 +0800 Message-ID: <20210730100158.3117319-5-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210730100158.3117319-1-ruansy.fnst@fujitsu.com> References: <20210730100158.3117319-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-yoursite-MailScanner-ID: 39DD64D0D4A2.A1089 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: ruansy.fnst@fujitsu.com X-Spam-Status: No Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With dax_holder notify support, we are able to notify the memory failure from pmem driver to upper layers. If there is something not support in the notify routine, memory_failure will fall back to the generic hanlder. Signed-off-by: Shiyang Ruan --- drivers/nvdimm/pmem.c | 13 +++++++++++++ mm/memory-failure.c | 14 ++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 1e0615b8565e..fea4ffc333b8 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -362,9 +362,22 @@ static void pmem_release_disk(void *__pmem) del_gendisk(pmem->disk); } +static int pmem_pagemap_memory_failure(struct dev_pagemap *pgmap, + unsigned long pfn, unsigned long nr_pfns, int flags) +{ + struct pmem_device *pmem = + container_of(pgmap, struct pmem_device, pgmap); + loff_t offset = PFN_PHYS(pfn) - pmem->phys_addr - pmem->data_offset; + + return dax_holder_notify_failure(pmem->dax_dev, offset, + page_size(pfn_to_page(pfn)) * nr_pfns, + &flags); +} + static const struct dev_pagemap_ops fsdax_pagemap_ops = { .kill = pmem_pagemap_kill, .cleanup = pmem_pagemap_cleanup, + .memory_failure = pmem_pagemap_memory_failure, }; static int pmem_attach_disk(struct device *dev, diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 3bdfcb45f66e..ab3eda335acd 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1600,6 +1600,20 @@ static int memory_failure_dev_pagemap(unsigned long pfn, int flags, */ SetPageHWPoison(page); + /* + * Call driver's implementation to handle the memory failure, otherwise + * fall back to generic handler. + */ + if (pgmap->ops->memory_failure) { + rc = pgmap->ops->memory_failure(pgmap, pfn, 1, flags); + /* + * Fall back to generic handler too if operation is not + * supported inside the driver/device/filesystem. + */ + if (rc != EOPNOTSUPP) + goto out; + } + mf_generic_kill_procs(pfn, flags); out: /* drop pgmap ref acquired in caller */ -- 2.32.0