From patchwork Wed Jan 13 07:14:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 12015915 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=BAYES_50, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3455BC433E0 for ; Wed, 13 Jan 2021 07:15:05 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C14D623134 for ; Wed, 13 Jan 2021 07:15:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C14D623134 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-nvdimm-bounces@lists.01.org Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 82205100EB324; Tue, 12 Jan 2021 23:15:02 -0800 (PST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=134.134.136.126; helo=mga18.intel.com; envelope-from=dan.j.williams@intel.com; receiver= Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 6CF67100EB323 for ; Tue, 12 Jan 2021 23:15:00 -0800 (PST) IronPort-SDR: K1DsPY5PsOIdqkyQz5Ue1vpC+/+nwV6394f38qeo9zZXSVNtc/9HBCqqh7yixNcysY26PE6wjA 0THCJcERNi1w== X-IronPort-AV: E=McAfee;i="6000,8403,9862"; a="165838245" X-IronPort-AV: E=Sophos;i="5.79,343,1602572400"; d="scan'208";a="165838245" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2021 23:14:59 -0800 IronPort-SDR: /bSuLbuqQuIqUVQI5dXxDNBvf9XoJRR1ktwkR9QVhy59N6TPj5wYnucTKLbkW2CeflQpXHACn+ bZeUOC19HXWA== X-IronPort-AV: E=Sophos;i="5.79,343,1602572400"; d="scan'208";a="345446680" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.25]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2021 23:14:58 -0800 Subject: [ndctl PATCH 1/4] ndctl/test: Fix btt expect table compile warning From: Dan Williams To: vishal.l.verma@intel.com Date: Tue, 12 Jan 2021 23:14:58 -0800 Message-ID: <161052209839.1804207.11951679046842122849.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <161052209289.1804207.11599120961607513911.stgit@dwillia2-desk3.amr.corp.intel.com> References: <161052209289.1804207.11599120961607513911.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 Message-ID-Hash: AC6Q3F3Z4FSASXCGETQPKSPQIU3UYMRX X-Message-ID-Hash: AC6Q3F3Z4FSASXCGETQPKSPQIU3UYMRX X-MailFrom: dan.j.williams@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: linux-nvdimm@lists.01.org X-Mailman-Version: 3.1.1 Precedence: list List-Id: "Linux-nvdimm developer list." Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: ../test/libndctl.c:989:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] 989 | unsigned long long expect_table[][2] = { | ^~~~~~~~ ...just move the declaration a few lines up. Signed-off-by: Dan Williams --- test/libndctl.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/libndctl.c b/test/libndctl.c index 24d72b382239..fc651499cc86 100644 --- a/test/libndctl.c +++ b/test/libndctl.c @@ -980,12 +980,6 @@ static int check_btt_size(struct ndctl_btt *btt) struct ndctl_ctx *ctx = ndctl_btt_get_ctx(btt); struct ndctl_test *test = ndctl_get_private_data(ctx); struct ndctl_namespace *ndns = ndctl_btt_get_namespace(btt); - - if (!ndns) - return -ENXIO; - - ns_size = ndctl_namespace_get_size(ndns); - sect_size = ndctl_btt_get_sector_size(btt); unsigned long long expect_table[][2] = { [0] = { [0] = 0x11b5400, @@ -1001,6 +995,12 @@ static int check_btt_size(struct ndctl_btt *btt) }, }; + if (!ndns) + return -ENXIO; + + ns_size = ndctl_namespace_get_size(ndns); + sect_size = ndctl_btt_get_sector_size(btt); + if (sect_size >= SZ_4K) sect_select = 1; else if (sect_size >= 512) From patchwork Wed Jan 13 07:15:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 12015917 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65BFAC433DB for ; Wed, 13 Jan 2021 07:15:08 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F12AD23136 for ; Wed, 13 Jan 2021 07:15:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F12AD23136 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-nvdimm-bounces@lists.01.org Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B1225100EB325; Tue, 12 Jan 2021 23:15:07 -0800 (PST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=dan.j.williams@intel.com; receiver= Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B905D100EB325 for ; Tue, 12 Jan 2021 23:15:04 -0800 (PST) IronPort-SDR: FEIjnLEZEYMyJsN3N69PC3mk0oOA6GEAvFJDCcxDy+kyaZp8qEbv87RL/OLB6KsMbpSR16/3yB makwWH6lmoAw== X-IronPort-AV: E=McAfee;i="6000,8403,9862"; a="262948693" X-IronPort-AV: E=Sophos;i="5.79,343,1602572400"; d="scan'208";a="262948693" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2021 23:15:04 -0800 IronPort-SDR: z8IAgj2FemypgMdubKPcxYH8GD1GiTM8GaTdlmc7+eOL6rKG3b4GRRZ71id9NxDqVCfHyr45aw gzUI75W95IOg== X-IronPort-AV: E=Sophos;i="5.79,343,1602572400"; d="scan'208";a="569336683" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.25]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2021 23:15:04 -0800 Subject: [ndctl PATCH 2/4] ndctl/test: Cleanup unnecessary out label From: Dan Williams To: vishal.l.verma@intel.com Date: Tue, 12 Jan 2021 23:15:03 -0800 Message-ID: <161052210395.1804207.7318263492906073721.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <161052209289.1804207.11599120961607513911.stgit@dwillia2-desk3.amr.corp.intel.com> References: <161052209289.1804207.11599120961607513911.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 Message-ID-Hash: W5WVD47DKXFI3HJUF2JP4FEWNRPOIG4D X-Message-ID-Hash: W5WVD47DKXFI3HJUF2JP4FEWNRPOIG4D X-MailFrom: dan.j.williams@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: linux-nvdimm@lists.01.org X-Mailman-Version: 3.1.1 Precedence: list List-Id: "Linux-nvdimm developer list." Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: There are no cleanup actions to take in test_dax_remap(), and it is already inconsistent for having a single return point, so remove the out label. Signed-off-by: Dan Williams --- test/dax-pmd.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/test/dax-pmd.c b/test/dax-pmd.c index 401826d02d69..b1251db63041 100644 --- a/test/dax-pmd.c +++ b/test/dax-pmd.c @@ -83,20 +83,18 @@ int test_dax_remap(struct ndctl_test *test, int dax_fd, unsigned long align, voi act.sa_flags = SA_SIGINFO; if (sigaction(SIGBUS, &act, 0)) { perror("sigaction"); - rc = EXIT_FAILURE; - goto out; + return EXIT_FAILURE; } /* test fault after device-dax instance disabled */ if (sigsetjmp(sj_env, 1)) { if (!fsdax && align > SZ_4K) { fprintf(stderr, "got expected SIGBUS after mremap() of device-dax\n"); - rc = 0; + return 0; } else { fprintf(stderr, "unpexpected SIGBUS after mremap()\n"); - rc = -EIO; + return -EIO; } - goto out; } *(int *) anon = 0xAA; @@ -107,9 +105,7 @@ int test_dax_remap(struct ndctl_test *test, int dax_fd, unsigned long align, voi return -ENXIO; } - rc = 0; -out: - return rc; + return 0; } int test_dax_directio(int dax_fd, unsigned long align, void *dax_addr, off_t offset) From patchwork Wed Jan 13 07:15:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 12015919 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E1FEC433DB for ; Wed, 13 Jan 2021 07:15:13 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1885923136 for ; Wed, 13 Jan 2021 07:15:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1885923136 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-nvdimm-bounces@lists.01.org Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id CB403100EB327; Tue, 12 Jan 2021 23:15:12 -0800 (PST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=dan.j.williams@intel.com; receiver= Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5A0C9100EB325 for ; Tue, 12 Jan 2021 23:15:10 -0800 (PST) IronPort-SDR: lJmW0lwIEoDFisvKaGsMptzxArfRvE4ZpwUEoXwJWp4bLRGg5Id5SDtiR5wskG13cty496QTtT PPcYPXyghUDQ== X-IronPort-AV: E=McAfee;i="6000,8403,9862"; a="165250663" X-IronPort-AV: E=Sophos;i="5.79,343,1602572400"; d="scan'208";a="165250663" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2021 23:15:09 -0800 IronPort-SDR: WvvCil86LLqhmtJueHzsSnDgcuBsx8a0kxDjsjKyr/heFFE9r6TMZVeWX62m8V8+WabYrWqVuo SP06PoL25bdA== X-IronPort-AV: E=Sophos;i="5.79,343,1602572400"; d="scan'208";a="381739835" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.25]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2021 23:15:09 -0800 Subject: [ndctl PATCH 3/4] ndctl/test: Fix device-dax mremap() test From: Dan Williams To: vishal.l.verma@intel.com Date: Tue, 12 Jan 2021 23:15:09 -0800 Message-ID: <161052210936.1804207.17896246772670985157.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <161052209289.1804207.11599120961607513911.stgit@dwillia2-desk3.amr.corp.intel.com> References: <161052209289.1804207.11599120961607513911.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 Message-ID-Hash: WMKP5N4EZAP7US3T46CGDK4WGRKLVR7N X-Message-ID-Hash: WMKP5N4EZAP7US3T46CGDK4WGRKLVR7N X-MailFrom: dan.j.williams@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: linux-nvdimm@lists.01.org X-Mailman-Version: 3.1.1 Precedence: list List-Id: "Linux-nvdimm developer list." Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: The test_dax_remap() test is a regression check for mishandling of mremap() in the presence of pmd_devmap(). My understanding is that it was a fuzzing condition not something an application would want to do in practice. On recent kernels with commit 73d5e0629919 ("mremap: check if it's possible to split original vma"), the test fails for device-dax. That seems an equally acceptable result of attempting this remap, so update the test rather than ask the kernel to preserve the old behaviour. Signed-off-by: Dan Williams --- test/dax-pmd.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/dax-pmd.c b/test/dax-pmd.c index b1251db63041..7648e348b0a6 100644 --- a/test/dax-pmd.c +++ b/test/dax-pmd.c @@ -69,6 +69,11 @@ int test_dax_remap(struct ndctl_test *test, int dax_fd, unsigned long align, voi remap = mremap(addr, REMAP_SIZE, REMAP_SIZE, MREMAP_MAYMOVE|MREMAP_FIXED, anon); + if (remap == MAP_FAILED) { + fprintf(stderr, "%s: mremap failed, that's ok too\n", __func__); + return 0; + } + if (remap != anon) { rc = -ENXIO; perror("mremap"); From patchwork Wed Jan 13 07:15:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 12015921 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 929B0C433DB for ; Wed, 13 Jan 2021 07:15:18 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 373B323136 for ; Wed, 13 Jan 2021 07:15:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 373B323136 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-nvdimm-bounces@lists.01.org Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id DFCA5100EB329; Tue, 12 Jan 2021 23:15:17 -0800 (PST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=192.55.52.151; helo=mga17.intel.com; envelope-from=dan.j.williams@intel.com; receiver= Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 71D7D100EB32C for ; Tue, 12 Jan 2021 23:15:15 -0800 (PST) IronPort-SDR: aVqTH0rG6KioOlqm0NW8aU2BpqtuhowtiGruwX8wzY8ZlKq80KCgvJO/YdppE6r0yixlaxGQKR +Z9Y9IMR57cg== X-IronPort-AV: E=McAfee;i="6000,8403,9862"; a="157938659" X-IronPort-AV: E=Sophos;i="5.79,343,1602572400"; d="scan'208";a="157938659" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2021 23:15:15 -0800 IronPort-SDR: ILGqLlhkIYIBWLAJgHcok1oPJeG2Di6ApLi0U0UX49cetuefwyfpSiMvC1d81mJSnQa9xIAQh0 Clo+9UKZcs1g== X-IronPort-AV: E=Sophos;i="5.79,343,1602572400"; d="scan'208";a="353346877" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.25]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2021 23:15:14 -0800 Subject: [ndctl PATCH 4/4] ndctl/test: Exercise soft_offline_page() corner cases From: Dan Williams To: vishal.l.verma@intel.com Date: Tue, 12 Jan 2021 23:15:14 -0800 Message-ID: <161052211455.1804207.13884321454837200896.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <161052209289.1804207.11599120961607513911.stgit@dwillia2-desk3.amr.corp.intel.com> References: <161052209289.1804207.11599120961607513911.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 Message-ID-Hash: LSZPSPYHGOTTRVE6JHQACKLH7P6O7IBK X-Message-ID-Hash: LSZPSPYHGOTTRVE6JHQACKLH7P6O7IBK X-MailFrom: dan.j.williams@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: linux-nvdimm@lists.01.org X-Mailman-Version: 3.1.1 Precedence: list List-Id: "Linux-nvdimm developer list." Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Test soft-offline injection into PMEM namespace metadata and user mapped space. Both attempts should fail on kernels with a pfn_to_online_page() implementation that considers subsection ZONE_DEVICE ranges. Signed-off-by: Dan Williams --- test/dax-poison.c | 19 +++++++++++++++++++ test/device-dax.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/test/dax-poison.c b/test/dax-poison.c index a4ef12eca1be..4e09761f0a5e 100644 --- a/test/dax-poison.c +++ b/test/dax-poison.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -49,6 +50,7 @@ int test_dax_poison(struct ndctl_test *test, int dax_fd, unsigned long align, unsigned char *addr = MAP_FAILED; struct sigaction act; unsigned x = x; + FILE *smaps; void *buf; int rc; @@ -94,6 +96,9 @@ int test_dax_poison(struct ndctl_test *test, int dax_fd, unsigned long align, goto out; } + fprintf(stderr, "%s: mmap got %p align: %ld offset: %zd\n", + __func__, addr, align, offset); + if (sigsetjmp(sj_env, 1)) { if (sig_mcerr_ar) { fprintf(stderr, "madvise triggered 'action required' sigbus\n"); @@ -104,6 +109,20 @@ int test_dax_poison(struct ndctl_test *test, int dax_fd, unsigned long align, } } + rc = madvise(addr + align / 2, 4096, MADV_SOFT_OFFLINE); + if (rc == 0) { + fprintf(stderr, "softoffline should always fail for dax\n"); + smaps = fopen("/proc/self/smaps", "r"); + do { + rc = fread(buf, 1, 4096, smaps); + fwrite(buf, 1, rc, stderr); + } while (rc); + fclose(smaps); + fail(); + rc = -ENXIO; + goto out; + } + rc = madvise(addr + align / 2, 4096, MADV_HWPOISON); if (rc) { fail(); diff --git a/test/device-dax.c b/test/device-dax.c index 5f0da297f28e..aad8fa5f1cb1 100644 --- a/test/device-dax.c +++ b/test/device-dax.c @@ -128,6 +128,44 @@ static int verify_data(struct daxctl_dev *dev, char *dax_buf, return 0; } +static int test_dax_soft_offline(struct ndctl_test *test, struct ndctl_namespace *ndns) +{ + unsigned long long resource = ndctl_namespace_get_resource(ndns); + int fd, rc; + char *buf; + + if (resource == ULLONG_MAX) { + fprintf(stderr, "failed to get resource: %s\n", + ndctl_namespace_get_devname(ndns)); + return -ENXIO; + } + + fd = open("/sys/devices/system/memory/soft_offline_page", O_WRONLY); + if (fd < 0) { + fprintf(stderr, "failed to open soft_offline_page\n"); + return -ENOENT; + } + + rc = asprintf(&buf, "%#llx\n", resource); + if (rc < 0) { + fprintf(stderr, "failed to alloc resource\n"); + close(fd); + return -ENOMEM; + } + + fprintf(stderr, "%s: try to offline page @%#llx\n", __func__, resource); + rc = write(fd, buf, rc); + free(buf); + close(fd); + + if (rc >= 0) { + fprintf(stderr, "%s: should have failed\n", __func__); + return -ENXIO; + } + + return 0; +} + static int __test_device_dax(unsigned long align, int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx) { @@ -278,6 +316,13 @@ static int __test_device_dax(unsigned long align, int loglevel, goto out; } + rc = test_dax_soft_offline(test, ndns); + if (rc) { + fprintf(stderr, "%s: failed dax soft offline\n", + ndctl_namespace_get_devname(ndns)); + goto out; + } + rc = test_dax_poison(test, fd, align, NULL, 0, devdax); if (rc) { fprintf(stderr, "%s: failed dax poison\n",