Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10016771imu; Wed, 5 Dec 2018 14:30:39 -0800 (PST) X-Google-Smtp-Source: AFSGD/VTnxjigrECm87kV+yaI4PVrKeOBjNU3vaJ2wLwCOIAsYYx6NxkMd5cwj6u6L0KRIt4Qdaz X-Received: by 2002:a63:d513:: with SMTP id c19mr22054127pgg.287.1544049039234; Wed, 05 Dec 2018 14:30:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544049039; cv=none; d=google.com; s=arc-20160816; b=GMxnlOvPaU7hsgolyrIum9/ImgRnB1okMNDiwHUX7JDcFhpV+zunO5yNshlG5wzNtm 3C/Slmk4Srom4QuH1qbDp83sXRxXXoAIxh3KNsCRwZUoy6O+Lb/Nx0gYLhYZ2YZgb2Gc wbF/t/CswZTY/d55Gr8nKBFgdEb+cbZomqqP5skgNcDqomW51iLCU6V4ufjM5C/kcQb0 7iSULLV/uRdP7WrALndV8axlaKGNHMwyx1qeE/m9NnqtBSfJuIcNyVRAqsmzjJ1prmPh usrSWEwDlgTLMttmEifUou30S1xKSsHKzHiGmpx+1mZelDPCJYjfljf4yi5T3S42shnT Rtbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject; bh=zHKl3KaPiVPm8VCYUxoKa+uGM1ESw5BqoAphO2Q/aMs=; b=wngTs4/UsrqubkwSOALm97eVi2tav3IRaBONPxyh6yuU/NsuGrX8HaizxiK7iLlORS 1ykzoexm4VmP9vy9GKPeZbB/r2+qCR59boSP+/MFJoVA6osn/GM9LVuPfElC4vuMLOCP F7rzhy+mZ2mY4Nw7PEk0t12fif5TqoMA5fuRgepEo/mUYN5zb48oE7Rhs1Kcoe/PVrm8 awL9purzCqB0smJedCSjwqLIwnNK6eNanbrYQtdzCG1Axn4yTLRJEXtEWCu0sHWvzxWK zOAP/t37lboYG9gg9Sx4E8ykc8boF2s/Z7pB2NGaE/zt3c6HtF9Pd6c2WVwyr/139j/V BbvA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s2si19032030pgj.60.2018.12.05.14.30.23; Wed, 05 Dec 2018 14:30:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728161AbeLEW2d (ORCPT + 99 others); Wed, 5 Dec 2018 17:28:33 -0500 Received: from mga07.intel.com ([134.134.136.100]:14110 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727358AbeLEW2c (ORCPT ); Wed, 5 Dec 2018 17:28:32 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Dec 2018 14:28:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,319,1539673200"; d="scan'208";a="125431878" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by fmsmga004.fm.intel.com with ESMTP; 05 Dec 2018 14:28:31 -0800 Subject: [PATCH v2] tools/testing/nvdimm: Align test resources to 128M From: Dan Williams To: linux-nvdimm@lists.01.org Cc: Vishal Verma , Vishal Verma , linux-kernel@vger.kernel.org Date: Wed, 05 Dec 2018 14:15:57 -0800 Message-ID: <154404811026.277309.7171897179868103531.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <154308521932.237140.13650270234597178173.stgit@dwillia2-desk3.amr.corp.intel.com> References: <154308521932.237140.13650270234597178173.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation for libnvdimm growing new restrictions to detect section conflicts between persistent memory regions, enable nfit_test to allocate aligned resources. Use a gen_pool to allocate nfit_test's fake resources in a separate address space from the virtual translation of the same. Reviewed-by: Vishal Verma Tested-by: Vishal Verma Signed-off-by: Dan Williams --- Changes in v2: * Fix intermittent crash from stale vmalloc() alias usage (Vishal) tools/testing/nvdimm/test/nfit.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c index 01ec04bf91b5..6c16ac36d482 100644 --- a/tools/testing/nvdimm/test/nfit.c +++ b/tools/testing/nvdimm/test/nfit.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -215,6 +216,8 @@ struct nfit_test { static struct workqueue_struct *nfit_wq; +static struct gen_pool *nfit_pool; + static struct nfit_test *to_nfit_test(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); @@ -1132,6 +1135,9 @@ static void release_nfit_res(void *data) list_del(&nfit_res->list); spin_unlock(&nfit_test_lock); + if (resource_size(&nfit_res->res) >= DIMM_SIZE) + gen_pool_free(nfit_pool, nfit_res->res.start, + resource_size(&nfit_res->res)); vfree(nfit_res->buf); kfree(nfit_res); } @@ -1144,7 +1150,7 @@ static void *__test_alloc(struct nfit_test *t, size_t size, dma_addr_t *dma, GFP_KERNEL); int rc; - if (!buf || !nfit_res) + if (!buf || !nfit_res || !*dma) goto err; rc = devm_add_action(dev, release_nfit_res, nfit_res); if (rc) @@ -1164,6 +1170,8 @@ static void *__test_alloc(struct nfit_test *t, size_t size, dma_addr_t *dma, return nfit_res->buf; err: + if (*dma && size >= DIMM_SIZE) + gen_pool_free(nfit_pool, *dma, size); if (buf) vfree(buf); kfree(nfit_res); @@ -1172,9 +1180,16 @@ static void *__test_alloc(struct nfit_test *t, size_t size, dma_addr_t *dma, static void *test_alloc(struct nfit_test *t, size_t size, dma_addr_t *dma) { + struct genpool_data_align data = { + .align = SZ_128M, + }; void *buf = vmalloc(size); - *dma = (unsigned long) buf; + if (size >= DIMM_SIZE) + *dma = gen_pool_alloc_algo(nfit_pool, size, + gen_pool_first_fit_align, &data); + else + *dma = (unsigned long) buf; return __test_alloc(t, size, dma, buf); } @@ -2839,6 +2854,17 @@ static __init int nfit_test_init(void) goto err_register; } + nfit_pool = gen_pool_create(ilog2(SZ_4M), NUMA_NO_NODE); + if (!nfit_pool) { + rc = -ENOMEM; + goto err_register; + } + + if (gen_pool_add(nfit_pool, SZ_4G, SZ_4G, NUMA_NO_NODE)) { + rc = -ENOMEM; + goto err_register; + } + for (i = 0; i < NUM_NFITS; i++) { struct nfit_test *nfit_test; struct platform_device *pdev; @@ -2894,6 +2920,9 @@ static __init int nfit_test_init(void) return 0; err_register: + if (nfit_pool) + gen_pool_destroy(nfit_pool); + destroy_workqueue(nfit_wq); for (i = 0; i < NUM_NFITS; i++) if (instances[i]) @@ -2917,6 +2946,8 @@ static __exit void nfit_test_exit(void) platform_driver_unregister(&nfit_test_driver); nfit_test_teardown(); + gen_pool_destroy(nfit_pool); + for (i = 0; i < NUM_NFITS; i++) put_device(&instances[i]->pdev.dev); class_destroy(nfit_test_dimm);