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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A2F0C433FE for ; Thu, 14 Oct 2021 18:05:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CA8EA60174 for ; Thu, 14 Oct 2021 18:05:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CA8EA60174 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 604E2900003; Thu, 14 Oct 2021 14:05:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5B441900002; Thu, 14 Oct 2021 14:05:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4A256900003; Thu, 14 Oct 2021 14:05:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0198.hostedemail.com [216.40.44.198]) by kanga.kvack.org (Postfix) with ESMTP id 3A47E900002 for ; Thu, 14 Oct 2021 14:05:09 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id DEF078249980 for ; Thu, 14 Oct 2021 18:05:08 +0000 (UTC) X-FDA: 78695819496.08.86A70F8 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf21.hostedemail.com (Postfix) with ESMTP id BD6A8D040B6B for ; Thu, 14 Oct 2021 18:05:07 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 7811E61156; Thu, 14 Oct 2021 18:05:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634234707; bh=Rqf9bmS83xeh3gCkrvLoUtzShhDQVtdQ2GWkdDACjQY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=K2OxDOj4FznqZrubwOPyMGzMHqGX17L7kfeSgXLp/+KyODPMHxpsiFkoPrIKO2qDL mZYZQEuF6syddsDF3heZBQ7jwZIz8dmD0WVRQ2Av5DhkmdY0+22qCGtv809c7Ze8Er WTglLurLQf0WfhK3SZl0nyUuEl+ZaZnB7GVzPx1VXQHwbugLIbDNVp9oMwsNMpGcEt PWY9ml3cpZ2bxt/JUKxCBSYvpYUtpcvyATECCVRF96dhMBlyjygp5xMOkK3kIAxt6C YlXwsKsKMgYGLjV15y4itRVFcpz0qtI2oFKPucHsjl2nH6lbJyZqWP/eJRwfb8lJ7e EA8BlYXkO5PFg== Date: Thu, 14 Oct 2021 11:05:07 -0700 From: "Darrick J. Wong" To: Shiyang Ruan Cc: linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, nvdimm@lists.linux.dev, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, dan.j.williams@intel.com, david@fromorbit.com, hch@infradead.org, jane.chu@oracle.com Subject: Re: [PATCH v7 4/8] pagemap,pmem: Introduce ->memory_failure() Message-ID: <20211014180507.GG24307@magnolia> References: <20210924130959.2695749-1-ruansy.fnst@fujitsu.com> <20210924130959.2695749-5-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210924130959.2695749-5-ruansy.fnst@fujitsu.com> X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: BD6A8D040B6B X-Stat-Signature: q5htfyiopdw844drtm54dmxusmn6bg31 Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=K2OxDOj4; spf=pass (imf21.hostedemail.com: domain of djwong@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=djwong@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-HE-Tag: 1634234707-269154 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, Sep 24, 2021 at 09:09:55PM +0800, Shiyang Ruan wrote: > When memory-failure occurs, we call this function which is implemented > by each kind of devices. For the fsdax case, pmem device driver > implements it. Pmem device driver will find out the filesystem in which > the corrupted page located in. > > 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 | 11 +++++++++++ > include/linux/memremap.h | 9 +++++++++ > mm/memory-failure.c | 14 ++++++++++++++ > 3 files changed, 34 insertions(+) > > diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c > index 72de88ff0d30..0dfafad8fcc5 100644 > --- a/drivers/nvdimm/pmem.c > +++ b/drivers/nvdimm/pmem.c > @@ -362,9 +362,20 @@ static void pmem_release_disk(void *__pmem) > del_gendisk(pmem->disk); > } > > +static int pmem_pagemap_memory_failure(struct dev_pagemap *pgmap, > + unsigned long pfn, size_t size, 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, size, 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/include/linux/memremap.h b/include/linux/memremap.h > index c0e9d35889e8..36d47bacd46d 100644 > --- a/include/linux/memremap.h > +++ b/include/linux/memremap.h > @@ -87,6 +87,15 @@ struct dev_pagemap_ops { > * the page back to a CPU accessible page. > */ > vm_fault_t (*migrate_to_ram)(struct vm_fault *vmf); > + > + /* > + * Handle the memory failure happens on a range of pfns. Notify the > + * processes who are using these pfns, and try to recover the data on > + * them if necessary. The flag is finally passed to the recover > + * function through the whole notify routine. > + */ > + int (*memory_failure)(struct dev_pagemap *pgmap, unsigned long pfn, > + size_t size, int flags); > }; > > #define PGMAP_ALTMAP_VALID (1 << 0) > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > index 8ff9b52823c0..85eab206b68f 100644 > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -1605,6 +1605,20 @@ static int memory_failure_dev_pagemap(unsigned long pfn, int flags, > if (!pgmap_pfn_valid(pgmap, pfn)) > goto out; > > + /* > + * 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, PAGE_SIZE, flags); > + /* > + * Fall back to generic handler too if operation is not > + * supported inside the driver/device/filesystem. > + */ > + if (rc != EOPNOTSUPP) -EOPNOTSUPP? (negative errno) --D > + goto out; > + } > + > rc = mf_generic_kill_procs(pfn, flags, pgmap); > out: > /* drop pgmap ref acquired in caller */ > -- > 2.33.0 > > >