From patchwork Fri Aug 26 17:17:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 12956331 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 10A64ECAAA6 for ; Fri, 26 Aug 2022 17:18:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A3C87940009; Fri, 26 Aug 2022 13:17:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9C511940008; Fri, 26 Aug 2022 13:17:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 865B8940009; Fri, 26 Aug 2022 13:17:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 7007D940008 for ; Fri, 26 Aug 2022 13:17:59 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 5006E1407FF for ; Fri, 26 Aug 2022 17:17:59 +0000 (UTC) X-FDA: 79842401478.15.A613CD4 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by imf27.hostedemail.com (Postfix) with ESMTP id C5B1E4001C for ; Fri, 26 Aug 2022 17:17:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661534277; x=1693070277; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eytTo9jR/taEQMRxBFsY1ZsO/Az6sn3vkXQeKBBLxVw=; b=Lpbwiy0PCJxBznubZnh3gqRaYURoCIF8HONg2G4MwU57SvF6Eo2/9zLb nuDSeUiL3LRQvngdbz0TLr5VXZ0ZRyuMV0yqFkuIfb8tb+s9JhQCzvtmg G+FMalmg6PcC+adMkQemNlKi5xT1MUHvnQIm/CxRg7S/wAlO3wC+ewdbF 6KCdwtDqIpgVzPQzNn1tZKDV9UidaBcEjT3sAgJ0aAI6nG9fyxRww9rZS USM94sFnzVr2DbsU3jm9d3JKsfUt03/ddNACVwcIKPiX9AWUlebiNYc9W i8PbmriVM9O8E6Mk6fhEXLuwdT4/U30rBUMvaJoerp5+FxA1aSHkbUv06 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10451"; a="292134701" X-IronPort-AV: E=Sophos;i="5.93,265,1654585200"; d="scan'208";a="292134701" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2022 10:17:55 -0700 X-IronPort-AV: E=Sophos;i="5.93,265,1654585200"; d="scan'208";a="714035729" Received: from jodirobx-mobl2.amr.corp.intel.com (HELO dwillia2-xfh.jf.intel.com) ([10.209.108.22]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2022 10:17:55 -0700 Subject: [PATCH 1/4] xfs: Quiet notify_failure EOPNOTSUPP cases From: Dan Williams To: akpm@linux-foundation.org, djwong@kernel.org Cc: Shiyang Ruan , Christoph Hellwig , Al Viro , Dave Chinner , Goldwyn Rodrigues , Jane Chu , Matthew Wilcox , Miaohe Lin , Naoya Horiguchi , Ritesh Harjani , nvdimm@lists.linux.dev, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Date: Fri, 26 Aug 2022 10:17:54 -0700 Message-ID: <166153427440.2758201.6709480562966161512.stgit@dwillia2-xfh.jf.intel.com> In-Reply-To: <166153426798.2758201.15108211981034512993.stgit@dwillia2-xfh.jf.intel.com> References: <166153426798.2758201.15108211981034512993.stgit@dwillia2-xfh.jf.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661534278; a=rsa-sha256; cv=none; b=UyvLgF+irV/NzLZR0HmJxQTreF8sZ+71pqYy7h3um5UsalGc6oJbFM30DLLYkPswNRpjpj 8AqSoOT03A3Rrd2ouM41f7lIGz4cKgXFkFvDNIZRXxUv2LPdSTOPVlTFKqyc6PV4V0ET5y kBAMi1CsaUsv3pgdOgkwJEmPW9sGu2Y= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=Lpbwiy0P; spf=pass (imf27.hostedemail.com: domain of dan.j.williams@intel.com designates 192.55.52.93 as permitted sender) smtp.mailfrom=dan.j.williams@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=1661534278; 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=iqDbMyfI58bvkuErkzvXodY4E63qe64qbSM99XN0T/M=; b=4ip3UuIPpy+87E5PsUdsaUtAgDtRyCL40HsxuWddx9V/olzBLrHisWgQRutftGQi/q2XUR +VBQnsA7YM1I3LxUzUZCuHqNIH4F0H+i2bH9yTG6bfIEwOZD5lSl3dVosmLt+AnG/Vo4DY +Ut4aiWz/2m5KZLVsmeOHmHXi1rEzBA= X-Stat-Signature: dq1t81uswcmpuoux9zb4deadcxzwkemp X-Rspamd-Queue-Id: C5B1E4001C Authentication-Results: imf27.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=Lpbwiy0P; spf=pass (imf27.hostedemail.com: domain of dan.j.williams@intel.com designates 192.55.52.93 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Rspam-User: X-Rspamd-Server: rspam02 X-HE-Tag: 1661534277-146172 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: XFS always registers dax_holder_operations regardless of whether the filesystem is capable of handling the notifications. The expectation is that if the notify_failure handler cannot run then there are no scenarios where it needs to run. In other words the expected semantic is that page->index and page->mapping are valid for memory_failure() when the conditions that cause -EOPNOTSUPP in xfs_dax_notify_failure() are present. A fallback to the generic memory_failure() path is expected so do not warn when that happens. Fixes: 6f643c57d57c ("xfs: implement ->notify_failure() for XFS") Cc: Shiyang Ruan Cc: Christoph Hellwig Cc: Darrick J. Wong Cc: Al Viro Cc: Dave Chinner Cc: Goldwyn Rodrigues Cc: Jane Chu Cc: Matthew Wilcox Cc: Miaohe Lin Cc: Naoya Horiguchi Cc: Ritesh Harjani Cc: Andrew Morton Signed-off-by: Dan Williams Reviewed-by: Christoph Hellwig --- fs/xfs/xfs_notify_failure.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_notify_failure.c b/fs/xfs/xfs_notify_failure.c index 69d9c83ea4b2..01e2721589c4 100644 --- a/fs/xfs/xfs_notify_failure.c +++ b/fs/xfs/xfs_notify_failure.c @@ -181,7 +181,7 @@ xfs_dax_notify_failure( } if (mp->m_rtdev_targp && mp->m_rtdev_targp->bt_daxdev == dax_dev) { - xfs_warn(mp, + xfs_debug(mp, "notify_failure() not supported on realtime device!"); return -EOPNOTSUPP; } @@ -194,7 +194,7 @@ xfs_dax_notify_failure( } if (!xfs_has_rmapbt(mp)) { - xfs_warn(mp, "notify_failure() needs rmapbt enabled!"); + xfs_debug(mp, "notify_failure() needs rmapbt enabled!"); return -EOPNOTSUPP; } From patchwork Fri Aug 26 17:18:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 12956332 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 1BE14ECAAA6 for ; Fri, 26 Aug 2022 17:18:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 97990940008; Fri, 26 Aug 2022 13:18:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 90126940007; Fri, 26 Aug 2022 13:18:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 77B06940008; Fri, 26 Aug 2022 13:18:05 -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 66396940007 for ; Fri, 26 Aug 2022 13:18:05 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 4A0441208CB for ; Fri, 26 Aug 2022 17:18:05 +0000 (UTC) X-FDA: 79842401730.04.6CC3C83 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by imf08.hostedemail.com (Postfix) with ESMTP id 99B38160020 for ; Fri, 26 Aug 2022 17:18:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661534284; x=1693070284; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fs681qlkVC3ILKSgH9kmbbCYwIlE7iUgG8xYi36A6tk=; b=KrXEKz34gVoq7UvTKy/9mN33zlY7N4lwQQYzv4l3J6RvTGdnlUABOZA4 QxR01PmVgg7bWAHcml9LBi5MBlkP9JiV4m3L7Wdukx+3hIknw3Yj6xDTS VKpqXkKjJjONDw0v/WNhvYU21gP9SKd6t4bRMaruS54gNbXIUdiujGY4a ZTMELyrKCoStYnn8kLhhsXtIC4AmfGYPzIJakosOM0Kh3lOdIp1XokihP eupBl4MNVC0NuWJfrWvZ29mDpQpsrQ5pibZsMffyDn4FQSR7ecnIi62VG uF3I7FXQd4CD760wwuEJIuw9TSFVOQV1ad+1k/cfYbrs9t3BfOK9tWlvD g==; X-IronPort-AV: E=McAfee;i="6500,9779,10451"; a="281525175" X-IronPort-AV: E=Sophos;i="5.93,265,1654585200"; d="scan'208";a="281525175" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2022 10:18:02 -0700 X-IronPort-AV: E=Sophos;i="5.93,265,1654585200"; d="scan'208";a="938824876" Received: from jodirobx-mobl2.amr.corp.intel.com (HELO dwillia2-xfh.jf.intel.com) ([10.209.108.22]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2022 10:18:01 -0700 Subject: [PATCH 2/4] xfs: Fix SB_BORN check in xfs_dax_notify_failure() From: Dan Williams To: akpm@linux-foundation.org, djwong@kernel.org Cc: Shiyang Ruan , Christoph Hellwig , Al Viro , Dave Chinner , Goldwyn Rodrigues , Jane Chu , Matthew Wilcox , Miaohe Lin , Naoya Horiguchi , Ritesh Harjani , nvdimm@lists.linux.dev, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Date: Fri, 26 Aug 2022 10:18:01 -0700 Message-ID: <166153428094.2758201.7936572520826540019.stgit@dwillia2-xfh.jf.intel.com> In-Reply-To: <166153426798.2758201.15108211981034512993.stgit@dwillia2-xfh.jf.intel.com> References: <166153426798.2758201.15108211981034512993.stgit@dwillia2-xfh.jf.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661534284; a=rsa-sha256; cv=none; b=Qj0MkGsp/KBbWhUmk00BpCGLAOke51tnfPXrUwCBz5VQZ3VDnyMCr9BvvA1hljvXxNJkm0 p7+iZQBH6f/xVOmTwysAbfeV1JIInL0JNuxu6CALzxxbFR/cku40gMNuZYiHaMrfcNVUyU WC61wcY/74v+fV31J+kL2tjli3m/s3g= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=KrXEKz34; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf08.hostedemail.com: domain of dan.j.williams@intel.com designates 134.134.136.20 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661534284; 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=UC6Wm4YSJnedVaSXqdXRRk0AwtwLVySpdJ8006OVW88=; b=MheUHq8YneJ0Nde95DuWZMZttp85GqUiTjB5WsG7mA1DNmmWGu1ttFufCuHbL1sOzj06w2 5K0JlrJxUjCaM9h3JZhNrR295tXWbZPVYaeUTr5ihHzv9AqMiegieiQu10i1nVCEaqJCJY HjkiLcahSVX+/zlrEo7aJ05y4e2bCqg= Authentication-Results: imf08.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=KrXEKz34; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf08.hostedemail.com: domain of dan.j.williams@intel.com designates 134.134.136.20 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: ezfa49c13xbjmzhybrzny36ujtkbkcc7 X-Rspamd-Queue-Id: 99B38160020 X-HE-Tag: 1661534284-433291 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: The SB_BORN flag is stored in the vfs superblock, not xfs_sb. Fixes: 6f643c57d57c ("xfs: implement ->notify_failure() for XFS") Cc: Shiyang Ruan Cc: Christoph Hellwig Cc: Darrick J. Wong Cc: Al Viro Cc: Dave Chinner Cc: Goldwyn Rodrigues Cc: Jane Chu Cc: Matthew Wilcox Cc: Miaohe Lin Cc: Naoya Horiguchi Cc: Ritesh Harjani Cc: Andrew Morton Signed-off-by: Dan Williams Reviewed-by: Christoph Hellwig --- fs/xfs/xfs_notify_failure.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/xfs/xfs_notify_failure.c b/fs/xfs/xfs_notify_failure.c index 01e2721589c4..5b1f9a24ed59 100644 --- a/fs/xfs/xfs_notify_failure.c +++ b/fs/xfs/xfs_notify_failure.c @@ -175,7 +175,7 @@ xfs_dax_notify_failure( u64 ddev_start; u64 ddev_end; - if (!(mp->m_sb.sb_flags & SB_BORN)) { + if (!(mp->m_super->s_flags & SB_BORN)) { xfs_warn(mp, "filesystem is not ready for notify_failure()!"); return -EIO; } From patchwork Fri Aug 26 17:18:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 12956333 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 BDB14ECAAD9 for ; Fri, 26 Aug 2022 17:18:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 50C5C94000A; Fri, 26 Aug 2022 13:18:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4944E940007; Fri, 26 Aug 2022 13:18:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 30E5094000A; Fri, 26 Aug 2022 13:18:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 195C0940007 for ; Fri, 26 Aug 2022 13:18:11 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id ED023120F88 for ; Fri, 26 Aug 2022 17:18:10 +0000 (UTC) X-FDA: 79842401940.30.A3A049B Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by imf24.hostedemail.com (Postfix) with ESMTP id 79B9D180027 for ; Fri, 26 Aug 2022 17:18:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661534290; x=1693070290; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GCTeJYnVfz9emV2HwJCGmwSTFAShgS49A/17AEqM6p0=; b=IxGUz5ikRi61KZo9aceGnpAvph0j5B01HAFjkpDWLA5mAAvJdaOjVq8z t0tTFI47wbJYIdzjdtUy9DEVsQCIIc17RpoIYcJ8rnker+2kW3kCQTOzs 3N5H5I4vKIAKYJKRPU/LIOuLuOKV4Fv76bFfn0UF5AT8KgvxpzWNaIxNz ljThUOMA62Pzv/g/FT643zgDA5FVtC+nK66/Uh/sgWFUV+K2i7g73/wg5 BDJXtN3FX4gsbPnuaa3A7FTstQs02W5uAkdz8INDOxUvofoJb2sNvmhQC gworVkME+sc2adqk6WLeuLsb57pEtffnAEnP22n0UOqJKWk6zbUVg/Gzc Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10451"; a="292134770" X-IronPort-AV: E=Sophos;i="5.93,265,1654585200"; d="scan'208";a="292134770" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2022 10:18:09 -0700 X-IronPort-AV: E=Sophos;i="5.93,265,1654585200"; d="scan'208";a="613590592" Received: from jodirobx-mobl2.amr.corp.intel.com (HELO dwillia2-xfh.jf.intel.com) ([10.209.108.22]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2022 10:18:08 -0700 Subject: [PATCH 3/4] mm/memory-failure: Fix detection of memory_failure() handlers From: Dan Williams To: akpm@linux-foundation.org, djwong@kernel.org Cc: Shiyang Ruan , Christoph Hellwig , Naoya Horiguchi , Al Viro , Dave Chinner , Goldwyn Rodrigues , Jane Chu , Matthew Wilcox , Miaohe Lin , Ritesh Harjani , nvdimm@lists.linux.dev, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Date: Fri, 26 Aug 2022 10:18:07 -0700 Message-ID: <166153428781.2758201.1990616683438224741.stgit@dwillia2-xfh.jf.intel.com> In-Reply-To: <166153426798.2758201.15108211981034512993.stgit@dwillia2-xfh.jf.intel.com> References: <166153426798.2758201.15108211981034512993.stgit@dwillia2-xfh.jf.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661534290; a=rsa-sha256; cv=none; b=pvDQD3PjrYxrFkf+Cz4pYwAaBcM6fLoGu6F5NTqbwYoI4B8ANoMV+2oFfKIKZlbQCtO4YO JGQ4uUh2SQD5v1hj8iqYFFH034nvX7y9mBmW87LJZvs2fW4Sk+JRluy1dDoaS9nAlEprKG 6kQAIcF0kXtwt0Mx4WpMu3jUSn9xK/o= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=IxGUz5ik; spf=pass (imf24.hostedemail.com: domain of dan.j.williams@intel.com designates 192.55.52.93 as permitted sender) smtp.mailfrom=dan.j.williams@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=1661534290; 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=7p7mivAdUgdSv+63I5JywdT+moKuaglvOu3RH2hKPB4=; b=gbQq0mLIMLryjhRGfG7wVayVBw5MSnaJgl2wkHDFSijbllRA7yumDAa91v8RoElYMuebRt NDIYHwc7BBDY2YpqVXrtnG4dLyQc3K50WhAWC8cMZ76k/YlI8JONDkMfWTc7WeBMeHIP9u 48P+4FS0eTH+IWS8DdJtXyOCKAcl8Xs= X-Rspam-User: Authentication-Results: imf24.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=IxGUz5ik; spf=pass (imf24.hostedemail.com: domain of dan.j.williams@intel.com designates 192.55.52.93 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Rspamd-Server: rspam08 X-Stat-Signature: xeb6hfwi53o97aj1r5w5ytpiywbhbnji X-Rspamd-Queue-Id: 79B9D180027 X-HE-Tag: 1661534290-298372 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: Some pagemap types, like MEMORY_DEVICE_GENERIC (device-dax) do not even have pagemap ops which results in crash signatures like this: BUG: kernel NULL pointer dereference, address: 0000000000000010 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 8000000205073067 P4D 8000000205073067 PUD 2062b3067 PMD 0 Oops: 0000 [#1] PREEMPT SMP PTI CPU: 22 PID: 4535 Comm: device-dax Tainted: G OE N 6.0.0-rc2+ #59 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015 RIP: 0010:memory_failure+0x667/0xba0 [..] Call Trace: ? _printk+0x58/0x73 do_madvise.part.0.cold+0xaf/0xc5 Check for ops before checking if the ops have a memory_failure() handler. Fixes: 33a8f7f2b3a3 ("pagemap,pmem: introduce ->memory_failure()") Cc: Shiyang Ruan Cc: Christoph Hellwig Cc: Darrick J. Wong Cc: Naoya Horiguchi Cc: Al Viro Cc: Dave Chinner Cc: Goldwyn Rodrigues Cc: Jane Chu Cc: Matthew Wilcox Cc: Miaohe Lin Cc: Ritesh Harjani Cc: Andrew Morton Signed-off-by: Dan Williams Acked-by: Naoya Horiguchi Reviewed-by: Miaohe Lin Reviewed-by: Christoph Hellwig --- include/linux/memremap.h | 5 +++++ mm/memory-failure.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/linux/memremap.h b/include/linux/memremap.h index 19010491a603..c3b4cc84877b 100644 --- a/include/linux/memremap.h +++ b/include/linux/memremap.h @@ -139,6 +139,11 @@ struct dev_pagemap { }; }; +static inline bool pgmap_has_memory_failure(struct dev_pagemap *pgmap) +{ + return pgmap->ops && pgmap->ops->memory_failure; +} + static inline struct vmem_altmap *pgmap_altmap(struct dev_pagemap *pgmap) { if (pgmap->flags & PGMAP_ALTMAP_VALID) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 14439806b5ef..8a4294afbfa0 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1928,7 +1928,7 @@ static int memory_failure_dev_pagemap(unsigned long pfn, int flags, * Call driver's implementation to handle the memory failure, otherwise * fall back to generic handler. */ - if (pgmap->ops->memory_failure) { + if (pgmap_has_memory_failure(pgmap)) { rc = pgmap->ops->memory_failure(pgmap, pfn, 1, flags); /* * Fall back to generic handler too if operation is not From patchwork Fri Aug 26 17:18:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 12956334 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 9FDF1ECAAA3 for ; Fri, 26 Aug 2022 17:18:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 35E5A940009; Fri, 26 Aug 2022 13:18:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E75C940007; Fri, 26 Aug 2022 13:18:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 16105940009; Fri, 26 Aug 2022 13:18:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 007AB940007 for ; Fri, 26 Aug 2022 13:18:17 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C6A1E1C66C0 for ; Fri, 26 Aug 2022 17:18:17 +0000 (UTC) X-FDA: 79842402234.14.C35B71E Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by imf30.hostedemail.com (Postfix) with ESMTP id 3451380039 for ; Fri, 26 Aug 2022 17:18:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661534297; x=1693070297; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LsOnSwP3WX7FSaGrxr4QTRIs8WWv2jITSkmOpyZ+1Mk=; b=GVjrFzbEJYpMt8oHROFop4AREKqJtA7I03SeXkpep7qBna4kpJuzLD4o vofWk29u6JPkrpITJjzpQr3jUJJC94fdYT233B1CrecCaiQD/fVTKhHIp iA53UScUDEkHwe6gwRmUMOIGvXgZ2EqiPUGLyxINvqMVyeRF40BMDu2JI 8afVXhXNvxuSCh7tXZq5d9BSA8UcaL69NSps2q6aChCZVmQrZGfEZZF5p /YnpwwRpfK35nd6QJ4MBxtNX2S9bqO7XfpwCfvicQgZYHStlo88iYLEhQ N9/3oo6lWk7GSo5UxBmC5TnO815Wh41PFo8WbDWQlv1wM8xDTkbJfN3IL g==; X-IronPort-AV: E=McAfee;i="6500,9779,10451"; a="281525253" X-IronPort-AV: E=Sophos;i="5.93,265,1654585200"; d="scan'208";a="281525253" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2022 10:18:15 -0700 X-IronPort-AV: E=Sophos;i="5.93,265,1654585200"; d="scan'208";a="678933461" Received: from jodirobx-mobl2.amr.corp.intel.com (HELO dwillia2-xfh.jf.intel.com) ([10.209.108.22]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2022 10:18:14 -0700 Subject: [PATCH 4/4] mm/memory-failure: Fall back to vma_address() when ->notify_failure() fails From: Dan Williams To: akpm@linux-foundation.org, djwong@kernel.org Cc: Shiyang Ruan , Christoph Hellwig , Naoya Horiguchi , Al Viro , Dave Chinner , Goldwyn Rodrigues , Jane Chu , Matthew Wilcox , Miaohe Lin , Ritesh Harjani , nvdimm@lists.linux.dev, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Date: Fri, 26 Aug 2022 10:18:14 -0700 Message-ID: <166153429427.2758201.14605968329933175594.stgit@dwillia2-xfh.jf.intel.com> In-Reply-To: <166153426798.2758201.15108211981034512993.stgit@dwillia2-xfh.jf.intel.com> References: <166153426798.2758201.15108211981034512993.stgit@dwillia2-xfh.jf.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661534297; a=rsa-sha256; cv=none; b=AtoVpmklzmaVDC8ULwA52/wjS6dEzaGrcub230H9AczToQGwADMo1XRpk2UcX6O95hJfXD FnFf4/1GZZZZgKCus+kDPOJ8NMRRNdC7nIwMjaevVP9LVL72jJie4Yr/+cgfwHwwcbGoi8 b+/LjjjEejozzM66Ctt/RUY8JZ5Svpc= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=GVjrFzbE; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf30.hostedemail.com: domain of dan.j.williams@intel.com designates 134.134.136.20 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661534297; 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=K9YvEPrW8YXSd/Y9gP4Lhzsbnd7nog6kf2LqSVcADMQ=; b=3POpSpApYMGc0o53OeLwNZBkNcEMZuZBytXud9DGS+lK6i05ZrRhoDq0KCv6ZcoSDEebHs o3kn7p8lV8HFYMHn7TsTRoLE52AtWWmO3LSLc92bTrtvNhMxsDKxWrkwsIGcVDeSYIYhM2 HdvNasVzH86CEu7eKkRRGOC06kWBpuQ= X-Rspamd-Queue-Id: 3451380039 Authentication-Results: imf30.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=GVjrFzbE; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf30.hostedemail.com: domain of dan.j.williams@intel.com designates 134.134.136.20 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com X-Rspam-User: X-Rspamd-Server: rspam01 X-Stat-Signature: eio7tq5qhjey6om71en7k5ytkepryiab X-HE-Tag: 1661534296-811716 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: In the case where a filesystem is polled to take over the memory failure and receives -EOPNOTSUPP it indicates that page->index and page->mapping are valid for reverse mapping the failure address. Introduce FSDAX_INVALID_PGOFF to distinguish when add_to_kill() is being called from mf_dax_kill_procs() by a filesytem vs the typical memory_failure() path. Otherwise, vma_pgoff_address() is called with an invalid fsdax_pgoff which then trips this failing signature: kernel BUG at mm/memory-failure.c:319! invalid opcode: 0000 [#1] PREEMPT SMP PTI CPU: 13 PID: 1262 Comm: dax-pmd Tainted: G OE N 6.0.0-rc2+ #62 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015 RIP: 0010:add_to_kill.cold+0x19d/0x209 [..] Call Trace: collect_procs.part.0+0x2c4/0x460 memory_failure+0x71b/0xba0 ? _printk+0x58/0x73 do_madvise.part.0.cold+0xaf/0xc5 Fixes: c36e20249571 ("mm: introduce mf_dax_kill_procs() for fsdax case") Cc: Shiyang Ruan Cc: Christoph Hellwig Cc: Darrick J. Wong Cc: Naoya Horiguchi Cc: Al Viro Cc: Dave Chinner Cc: Goldwyn Rodrigues Cc: Jane Chu Cc: Matthew Wilcox Cc: Miaohe Lin Cc: Ritesh Harjani Cc: Andrew Morton Signed-off-by: Dan Williams Acked-by: Naoya Horiguchi Reviewed-by: Miaohe Lin Reviewed-by: Christoph Hellwig --- mm/memory-failure.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 8a4294afbfa0..e424a9dac749 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -345,13 +345,17 @@ static unsigned long dev_pagemap_mapping_shift(struct vm_area_struct *vma, * not much we can do. We just print a message and ignore otherwise. */ +#define FSDAX_INVALID_PGOFF ULONG_MAX + /* * Schedule a process for later kill. * Uses GFP_ATOMIC allocations to avoid potential recursions in the VM. * - * Notice: @fsdax_pgoff is used only when @p is a fsdax page. - * In other cases, such as anonymous and file-backend page, the address to be - * killed can be caculated by @p itself. + * Note: @fsdax_pgoff is used only when @p is a fsdax page and a + * filesystem with a memory failure handler has claimed the + * memory_failure event. In all other cases, page->index and + * page->mapping are sufficient for mapping the page back to its + * corresponding user virtual address. */ static void add_to_kill(struct task_struct *tsk, struct page *p, pgoff_t fsdax_pgoff, struct vm_area_struct *vma, @@ -367,11 +371,7 @@ static void add_to_kill(struct task_struct *tsk, struct page *p, tk->addr = page_address_in_vma(p, vma); if (is_zone_device_page(p)) { - /* - * Since page->mapping is not used for fsdax, we need - * calculate the address based on the vma. - */ - if (p->pgmap->type == MEMORY_DEVICE_FS_DAX) + if (fsdax_pgoff != FSDAX_INVALID_PGOFF) tk->addr = vma_pgoff_address(fsdax_pgoff, 1, vma); tk->size_shift = dev_pagemap_mapping_shift(vma, tk->addr); } else @@ -523,7 +523,8 @@ static void collect_procs_anon(struct page *page, struct list_head *to_kill, if (!page_mapped_in_vma(page, vma)) continue; if (vma->vm_mm == t->mm) - add_to_kill(t, page, 0, vma, to_kill); + add_to_kill(t, page, FSDAX_INVALID_PGOFF, vma, + to_kill); } } read_unlock(&tasklist_lock); @@ -559,7 +560,8 @@ static void collect_procs_file(struct page *page, struct list_head *to_kill, * to be informed of all such data corruptions. */ if (vma->vm_mm == t->mm) - add_to_kill(t, page, 0, vma, to_kill); + add_to_kill(t, page, FSDAX_INVALID_PGOFF, vma, + to_kill); } } read_unlock(&tasklist_lock);