All of lore.kernel.org
 help / color / mirror / Atom feed
* fix a pmem regression due to drain the block queue in del_gendisk
@ 2021-10-19  7:36 Christoph Hellwig
  2021-10-19  7:36 ` [PATCH 1/2] nvdimm/pmem: stop using q_usage_count as external pgmap refcount Christoph Hellwig
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Christoph Hellwig @ 2021-10-19  7:36 UTC (permalink / raw)
  To: Dan Williams
  Cc: Vishal Verma, Dave Jiang, Ira Weiny, Jens Axboe, Yi Zhang,
	linux-block, nvdimm, linux-mm

Hi Dan,

this series fixes my recently introduced regression in the pmem driver by
removing the usage of q_usage_count as the external pgmap refcount in the
pmem driver and then removes the now unused external refcount
infrastructure.

Diffstat:
 drivers/nvdimm/pmem.c             |   33 +--------------------
 include/linux/memremap.h          |   18 +----------
 mm/memremap.c                     |   59 +++++++-------------------------------
 tools/testing/nvdimm/test/iomap.c |   43 +++++++--------------------
 4 files changed, 29 insertions(+), 124 deletions(-)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/2] nvdimm/pmem: stop using q_usage_count as external pgmap refcount
  2021-10-19  7:36 fix a pmem regression due to drain the block queue in del_gendisk Christoph Hellwig
@ 2021-10-19  7:36 ` Christoph Hellwig
  2021-10-19  7:36 ` [PATCH 2/2] memremap: remove support for external pgmap refcounts Christoph Hellwig
  2021-10-20  6:38 ` fix a pmem regression due to drain the block queue in del_gendisk Yi Zhang
  2 siblings, 0 replies; 14+ messages in thread
From: Christoph Hellwig @ 2021-10-19  7:36 UTC (permalink / raw)
  To: Dan Williams
  Cc: Vishal Verma, Dave Jiang, Ira Weiny, Jens Axboe, Yi Zhang,
	linux-block, nvdimm, linux-mm

Originally all DAX access when through block_device operations and thus
needed a queue reference.  But since commit cccbce671582
("filesystem-dax: convert to dax_direct_access()") all this happens at
the DAX device level which uses its own refcounting.  Having the external
refcount thus wasn't needed but has otherwise been harmless for long
time.

But now that "block: drain file system I/O on del_gendisk" waits for
q_usage_count to reach 0 in del_gendisk this whole scheme can't work
anymore (and pmem is the only driver abusing q_usage_count like that).
So switch to the internal reference and remove the unbalanced
blk_freeze_queue_start that is taken care of by del_gendisk.

Fixes: 8e141f9eb803 ("block: drain file system I/O on del_gendisk")
Reported-by: Yi Zhang <yi.zhang@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/nvdimm/pmem.c | 33 ++-------------------------------
 1 file changed, 2 insertions(+), 31 deletions(-)

diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index 72de88ff0d30d..f576ee0ce7968 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -333,26 +333,6 @@ static const struct attribute_group *pmem_attribute_groups[] = {
 	NULL,
 };
 
-static void pmem_pagemap_cleanup(struct dev_pagemap *pgmap)
-{
-	struct pmem_device *pmem = pgmap->owner;
-
-	blk_cleanup_disk(pmem->disk);
-}
-
-static void pmem_release_queue(void *pgmap)
-{
-	pmem_pagemap_cleanup(pgmap);
-}
-
-static void pmem_pagemap_kill(struct dev_pagemap *pgmap)
-{
-	struct request_queue *q =
-		container_of(pgmap->ref, struct request_queue, q_usage_counter);
-
-	blk_freeze_queue_start(q);
-}
-
 static void pmem_release_disk(void *__pmem)
 {
 	struct pmem_device *pmem = __pmem;
@@ -360,12 +340,9 @@ static void pmem_release_disk(void *__pmem)
 	kill_dax(pmem->dax_dev);
 	put_dax(pmem->dax_dev);
 	del_gendisk(pmem->disk);
-}
 
-static const struct dev_pagemap_ops fsdax_pagemap_ops = {
-	.kill			= pmem_pagemap_kill,
-	.cleanup		= pmem_pagemap_cleanup,
-};
+	blk_cleanup_disk(pmem->disk);
+}
 
 static int pmem_attach_disk(struct device *dev,
 		struct nd_namespace_common *ndns)
@@ -428,10 +405,8 @@ static int pmem_attach_disk(struct device *dev,
 	pmem->disk = disk;
 	pmem->pgmap.owner = pmem;
 	pmem->pfn_flags = PFN_DEV;
-	pmem->pgmap.ref = &q->q_usage_counter;
 	if (is_nd_pfn(dev)) {
 		pmem->pgmap.type = MEMORY_DEVICE_FS_DAX;
-		pmem->pgmap.ops = &fsdax_pagemap_ops;
 		addr = devm_memremap_pages(dev, &pmem->pgmap);
 		pfn_sb = nd_pfn->pfn_sb;
 		pmem->data_offset = le64_to_cpu(pfn_sb->dataoff);
@@ -445,16 +420,12 @@ static int pmem_attach_disk(struct device *dev,
 		pmem->pgmap.range.end = res->end;
 		pmem->pgmap.nr_range = 1;
 		pmem->pgmap.type = MEMORY_DEVICE_FS_DAX;
-		pmem->pgmap.ops = &fsdax_pagemap_ops;
 		addr = devm_memremap_pages(dev, &pmem->pgmap);
 		pmem->pfn_flags |= PFN_MAP;
 		bb_range = pmem->pgmap.range;
 	} else {
 		addr = devm_memremap(dev, pmem->phys_addr,
 				pmem->size, ARCH_MEMREMAP_PMEM);
-		if (devm_add_action_or_reset(dev, pmem_release_queue,
-					&pmem->pgmap))
-			return -ENOMEM;
 		bb_range.start =  res->start;
 		bb_range.end = res->end;
 	}
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/2] memremap: remove support for external pgmap refcounts
  2021-10-19  7:36 fix a pmem regression due to drain the block queue in del_gendisk Christoph Hellwig
  2021-10-19  7:36 ` [PATCH 1/2] nvdimm/pmem: stop using q_usage_count as external pgmap refcount Christoph Hellwig
@ 2021-10-19  7:36 ` Christoph Hellwig
  2021-10-21 13:40   ` Adam Borowski
                     ` (2 more replies)
  2021-10-20  6:38 ` fix a pmem regression due to drain the block queue in del_gendisk Yi Zhang
  2 siblings, 3 replies; 14+ messages in thread
From: Christoph Hellwig @ 2021-10-19  7:36 UTC (permalink / raw)
  To: Dan Williams
  Cc: Vishal Verma, Dave Jiang, Ira Weiny, Jens Axboe, Yi Zhang,
	linux-block, nvdimm, linux-mm

No driver is left using the external pgmap refcount, so remove the
code to support it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 include/linux/memremap.h          | 18 ++--------
 mm/memremap.c                     | 59 +++++++------------------------
 tools/testing/nvdimm/test/iomap.c | 43 +++++++---------------
 3 files changed, 27 insertions(+), 93 deletions(-)

diff --git a/include/linux/memremap.h b/include/linux/memremap.h
index c0e9d35889e8d..a8bc588fe7aa8 100644
--- a/include/linux/memremap.h
+++ b/include/linux/memremap.h
@@ -72,16 +72,6 @@ struct dev_pagemap_ops {
 	 */
 	void (*page_free)(struct page *page);
 
-	/*
-	 * Transition the refcount in struct dev_pagemap to the dead state.
-	 */
-	void (*kill)(struct dev_pagemap *pgmap);
-
-	/*
-	 * Wait for refcount in struct dev_pagemap to be idle and reap it.
-	 */
-	void (*cleanup)(struct dev_pagemap *pgmap);
-
 	/*
 	 * Used for private (un-addressable) device memory only.  Must migrate
 	 * the page back to a CPU accessible page.
@@ -95,8 +85,7 @@ struct dev_pagemap_ops {
  * struct dev_pagemap - metadata for ZONE_DEVICE mappings
  * @altmap: pre-allocated/reserved memory for vmemmap allocations
  * @ref: reference count that pins the devm_memremap_pages() mapping
- * @internal_ref: internal reference if @ref is not provided by the caller
- * @done: completion for @internal_ref
+ * @done: completion for @ref
  * @type: memory type: see MEMORY_* in memory_hotplug.h
  * @flags: PGMAP_* flags to specify defailed behavior
  * @ops: method table
@@ -109,8 +98,7 @@ struct dev_pagemap_ops {
  */
 struct dev_pagemap {
 	struct vmem_altmap altmap;
-	struct percpu_ref *ref;
-	struct percpu_ref internal_ref;
+	struct percpu_ref ref;
 	struct completion done;
 	enum memory_type type;
 	unsigned int flags;
@@ -191,7 +179,7 @@ static inline unsigned long memremap_compat_align(void)
 static inline void put_dev_pagemap(struct dev_pagemap *pgmap)
 {
 	if (pgmap)
-		percpu_ref_put(pgmap->ref);
+		percpu_ref_put(&pgmap->ref);
 }
 
 #endif /* _LINUX_MEMREMAP_H_ */
diff --git a/mm/memremap.c b/mm/memremap.c
index ed593bf87109a..d7034c55d0a24 100644
--- a/mm/memremap.c
+++ b/mm/memremap.c
@@ -112,30 +112,6 @@ static unsigned long pfn_next(unsigned long pfn)
 #define for_each_device_pfn(pfn, map, i) \
 	for (pfn = pfn_first(map, i); pfn < pfn_end(map, i); pfn = pfn_next(pfn))
 
-static void dev_pagemap_kill(struct dev_pagemap *pgmap)
-{
-	if (pgmap->ops && pgmap->ops->kill)
-		pgmap->ops->kill(pgmap);
-	else
-		percpu_ref_kill(pgmap->ref);
-}
-
-static void dev_pagemap_cleanup(struct dev_pagemap *pgmap)
-{
-	if (pgmap->ops && pgmap->ops->cleanup) {
-		pgmap->ops->cleanup(pgmap);
-	} else {
-		wait_for_completion(&pgmap->done);
-		percpu_ref_exit(pgmap->ref);
-	}
-	/*
-	 * Undo the pgmap ref assignment for the internal case as the
-	 * caller may re-enable the same pgmap.
-	 */
-	if (pgmap->ref == &pgmap->internal_ref)
-		pgmap->ref = NULL;
-}
-
 static void pageunmap_range(struct dev_pagemap *pgmap, int range_id)
 {
 	struct range *range = &pgmap->ranges[range_id];
@@ -167,11 +143,12 @@ void memunmap_pages(struct dev_pagemap *pgmap)
 	unsigned long pfn;
 	int i;
 
-	dev_pagemap_kill(pgmap);
+	percpu_ref_kill(&pgmap->ref);
 	for (i = 0; i < pgmap->nr_range; i++)
 		for_each_device_pfn(pfn, pgmap, i)
 			put_page(pfn_to_page(pfn));
-	dev_pagemap_cleanup(pgmap);
+	wait_for_completion(&pgmap->done);
+	percpu_ref_exit(&pgmap->ref);
 
 	for (i = 0; i < pgmap->nr_range; i++)
 		pageunmap_range(pgmap, i);
@@ -188,8 +165,7 @@ static void devm_memremap_pages_release(void *data)
 
 static void dev_pagemap_percpu_release(struct percpu_ref *ref)
 {
-	struct dev_pagemap *pgmap =
-		container_of(ref, struct dev_pagemap, internal_ref);
+	struct dev_pagemap *pgmap = container_of(ref, struct dev_pagemap, ref);
 
 	complete(&pgmap->done);
 }
@@ -295,8 +271,8 @@ static int pagemap_range(struct dev_pagemap *pgmap, struct mhp_params *params,
 	memmap_init_zone_device(&NODE_DATA(nid)->node_zones[ZONE_DEVICE],
 				PHYS_PFN(range->start),
 				PHYS_PFN(range_len(range)), pgmap);
-	percpu_ref_get_many(pgmap->ref, pfn_end(pgmap, range_id)
-			- pfn_first(pgmap, range_id));
+	percpu_ref_get_many(&pgmap->ref,
+		pfn_end(pgmap, range_id) - pfn_first(pgmap, range_id));
 	return 0;
 
 err_add_memory:
@@ -362,22 +338,11 @@ void *memremap_pages(struct dev_pagemap *pgmap, int nid)
 		break;
 	}
 
-	if (!pgmap->ref) {
-		if (pgmap->ops && (pgmap->ops->kill || pgmap->ops->cleanup))
-			return ERR_PTR(-EINVAL);
-
-		init_completion(&pgmap->done);
-		error = percpu_ref_init(&pgmap->internal_ref,
-				dev_pagemap_percpu_release, 0, GFP_KERNEL);
-		if (error)
-			return ERR_PTR(error);
-		pgmap->ref = &pgmap->internal_ref;
-	} else {
-		if (!pgmap->ops || !pgmap->ops->kill || !pgmap->ops->cleanup) {
-			WARN(1, "Missing reference count teardown definition\n");
-			return ERR_PTR(-EINVAL);
-		}
-	}
+	init_completion(&pgmap->done);
+	error = percpu_ref_init(&pgmap->ref, dev_pagemap_percpu_release, 0,
+				GFP_KERNEL);
+	if (error)
+		return ERR_PTR(error);
 
 	devmap_managed_enable_get(pgmap);
 
@@ -486,7 +451,7 @@ struct dev_pagemap *get_dev_pagemap(unsigned long pfn,
 	/* fall back to slow path lookup */
 	rcu_read_lock();
 	pgmap = xa_load(&pgmap_array, PHYS_PFN(phys));
-	if (pgmap && !percpu_ref_tryget_live(pgmap->ref))
+	if (pgmap && !percpu_ref_tryget_live(&pgmap->ref))
 		pgmap = NULL;
 	rcu_read_unlock();
 
diff --git a/tools/testing/nvdimm/test/iomap.c b/tools/testing/nvdimm/test/iomap.c
index ed563bdd88f39..b752ce47ead3c 100644
--- a/tools/testing/nvdimm/test/iomap.c
+++ b/tools/testing/nvdimm/test/iomap.c
@@ -100,25 +100,17 @@ static void nfit_test_kill(void *_pgmap)
 {
 	struct dev_pagemap *pgmap = _pgmap;
 
-	WARN_ON(!pgmap || !pgmap->ref);
-
-	if (pgmap->ops && pgmap->ops->kill)
-		pgmap->ops->kill(pgmap);
-	else
-		percpu_ref_kill(pgmap->ref);
-
-	if (pgmap->ops && pgmap->ops->cleanup) {
-		pgmap->ops->cleanup(pgmap);
-	} else {
-		wait_for_completion(&pgmap->done);
-		percpu_ref_exit(pgmap->ref);
-	}
+	WARN_ON(!pgmap);
+
+	percpu_ref_kill(&pgmap->ref);
+
+	wait_for_completion(&pgmap->done);
+	percpu_ref_exit(&pgmap->ref);
 }
 
 static void dev_pagemap_percpu_release(struct percpu_ref *ref)
 {
-	struct dev_pagemap *pgmap =
-		container_of(ref, struct dev_pagemap, internal_ref);
+	struct dev_pagemap *pgmap = container_of(ref, struct dev_pagemap, ref);
 
 	complete(&pgmap->done);
 }
@@ -132,22 +124,11 @@ void *__wrap_devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap)
 	if (!nfit_res)
 		return devm_memremap_pages(dev, pgmap);
 
-	if (!pgmap->ref) {
-		if (pgmap->ops && (pgmap->ops->kill || pgmap->ops->cleanup))
-			return ERR_PTR(-EINVAL);
-
-		init_completion(&pgmap->done);
-		error = percpu_ref_init(&pgmap->internal_ref,
-				dev_pagemap_percpu_release, 0, GFP_KERNEL);
-		if (error)
-			return ERR_PTR(error);
-		pgmap->ref = &pgmap->internal_ref;
-	} else {
-		if (!pgmap->ops || !pgmap->ops->kill || !pgmap->ops->cleanup) {
-			WARN(1, "Missing reference count teardown definition\n");
-			return ERR_PTR(-EINVAL);
-		}
-	}
+	init_completion(&pgmap->done);
+	error = percpu_ref_init(&pgmap->ref, dev_pagemap_percpu_release, 0,
+				GFP_KERNEL);
+	if (error)
+		return ERR_PTR(error);
 
 	error = devm_add_action_or_reset(dev, nfit_test_kill, pgmap);
 	if (error)
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: fix a pmem regression due to drain the block queue in del_gendisk
  2021-10-19  7:36 fix a pmem regression due to drain the block queue in del_gendisk Christoph Hellwig
  2021-10-19  7:36 ` [PATCH 1/2] nvdimm/pmem: stop using q_usage_count as external pgmap refcount Christoph Hellwig
  2021-10-19  7:36 ` [PATCH 2/2] memremap: remove support for external pgmap refcounts Christoph Hellwig
@ 2021-10-20  6:38 ` Yi Zhang
  2 siblings, 0 replies; 14+ messages in thread
From: Yi Zhang @ 2021-10-20  6:38 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Dan Williams, Vishal Verma, Dave Jiang, Ira Weiny, Jens Axboe,
	linux-block, Linux NVDIMM, linux-mm

Verified the issue was fixed by this patchset.
https://lore.kernel.org/linux-block/CAHj4cs87BapQJcV0a=M6=dc9PrsGH6qzqJEt9fbjLK1aShnMPg@mail.gmail.com/

Tested-by: Yi Zhang <yi.zhang@redhat.com>


On Tue, Oct 19, 2021 at 3:37 PM Christoph Hellwig <hch@lst.de> wrote:
>
> Hi Dan,
>
> this series fixes my recently introduced regression in the pmem driver by
> removing the usage of q_usage_count as the external pgmap refcount in the
> pmem driver and then removes the now unused external refcount
> infrastructure.
>
> Diffstat:
>  drivers/nvdimm/pmem.c             |   33 +--------------------
>  include/linux/memremap.h          |   18 +----------
>  mm/memremap.c                     |   59 +++++++-------------------------------
>  tools/testing/nvdimm/test/iomap.c |   43 +++++++--------------------
>  4 files changed, 29 insertions(+), 124 deletions(-)
>


--
Best Regards,
  Yi Zhang


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/2] memremap: remove support for external pgmap refcounts
  2021-10-19  7:36 ` [PATCH 2/2] memremap: remove support for external pgmap refcounts Christoph Hellwig
@ 2021-10-21 13:40   ` Adam Borowski
  2021-10-22  5:55     ` Christoph Hellwig
  2021-11-06  5:35     ` kernel test robot
  2021-11-14  0:13   ` kernel test robot
  2 siblings, 1 reply; 14+ messages in thread
From: Adam Borowski @ 2021-10-21 13:40 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Dan Williams, Vishal Verma, Dave Jiang, Ira Weiny, Jens Axboe,
	Yi Zhang, linux-block, nvdimm, linux-mm

On Tue, Oct 19, 2021 at 09:36:41AM +0200, Christoph Hellwig wrote:
> No driver is left using the external pgmap refcount, so remove the
> code to support it.

> --- a/include/linux/memremap.h
> +++ b/include/linux/memremap.h
> @@ -109,8 +98,7 @@ struct dev_pagemap_ops {
>   */
>  struct dev_pagemap {
>  	struct vmem_altmap altmap;
> -	struct percpu_ref *ref;
> -	struct percpu_ref internal_ref;
> +	struct percpu_ref ref;
>  	struct completion done;
>  	enum memory_type type;
>  	unsigned int flags;

This breaks at least drivers/pci/p2pdma.c:222


Meow!
-- 
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁
⢿⡄⠘⠷⠚⠋⠀ Certified airhead; got the CT scan to prove that!
⠈⠳⣄⠀⠀⠀⠀

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/2] memremap: remove support for external pgmap refcounts
  2021-10-21 13:40   ` Adam Borowski
@ 2021-10-22  5:55     ` Christoph Hellwig
  2021-10-22  8:52       ` Adam Borowski
  2021-10-22 15:43       ` Dan Williams
  0 siblings, 2 replies; 14+ messages in thread
From: Christoph Hellwig @ 2021-10-22  5:55 UTC (permalink / raw)
  To: Adam Borowski
  Cc: Christoph Hellwig, Dan Williams, Vishal Verma, Dave Jiang,
	Ira Weiny, Jens Axboe, Yi Zhang, linux-block, nvdimm, linux-mm

On Thu, Oct 21, 2021 at 03:40:17PM +0200, Adam Borowski wrote:
> This breaks at least drivers/pci/p2pdma.c:222

Indeed.  I've updated this patch, but the fix we need to urgently
get into 5.15-rc is the first one only anyway.

nvdimm maintainers, can you please act on it ASAP?

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/2] memremap: remove support for external pgmap refcounts
  2021-10-22  5:55     ` Christoph Hellwig
@ 2021-10-22  8:52       ` Adam Borowski
  2021-10-22 15:43       ` Dan Williams
  1 sibling, 0 replies; 14+ messages in thread
From: Adam Borowski @ 2021-10-22  8:52 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Dan Williams, Vishal Verma, Dave Jiang, Ira Weiny, Jens Axboe,
	Yi Zhang, linux-block, nvdimm, linux-mm

On Fri, Oct 22, 2021 at 07:55:15AM +0200, Christoph Hellwig wrote:
> On Thu, Oct 21, 2021 at 03:40:17PM +0200, Adam Borowski wrote:
> > This breaks at least drivers/pci/p2pdma.c:222
> 
> Indeed.  I've updated this patch, but the fix we need to urgently
> get into 5.15-rc is the first one only anyway.
> 
> nvdimm maintainers, can you please act on it ASAP?

As for build tests, after the p2pdma thingy I've tried all{yes,no,mod}config
and a handful of randconfigs, looks like it was the only place you missed.

As for runtime, a bunch of ndctl uses work fine with no explosions.

Thus: Tested-By.


Meow!
-- 
⢀⣴⠾⠻⢶⣦⠀ Don't be racist.  White, amber or black, all beers should
⣾⠁⢠⠒⠀⣿⡁ be judged based solely on their merits.  Heck, even if a
⢿⡄⠘⠷⠚⠋⠀ cider applies for a beer's job, why not?
⠈⠳⣄⠀⠀⠀⠀ On the other hand, mass-produced lager is not a race.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/2] memremap: remove support for external pgmap refcounts
  2021-10-22  5:55     ` Christoph Hellwig
  2021-10-22  8:52       ` Adam Borowski
@ 2021-10-22 15:43       ` Dan Williams
  2021-10-26  1:42         ` Dan Williams
  1 sibling, 1 reply; 14+ messages in thread
From: Dan Williams @ 2021-10-22 15:43 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Adam Borowski, Vishal Verma, Dave Jiang, Ira Weiny, Jens Axboe,
	Yi Zhang, linux-block, Linux NVDIMM, Linux MM

On Thu, Oct 21, 2021 at 10:55 PM Christoph Hellwig <hch@lst.de> wrote:
>
> On Thu, Oct 21, 2021 at 03:40:17PM +0200, Adam Borowski wrote:
> > This breaks at least drivers/pci/p2pdma.c:222
>
> Indeed.  I've updated this patch, but the fix we need to urgently
> get into 5.15-rc is the first one only anyway.
>
> nvdimm maintainers, can you please act on it ASAP?

Yes, I have been pulled in many directions this past week, but I do
plan to get this queued for v5.15-rc7.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/2] memremap: remove support for external pgmap refcounts
  2021-10-22 15:43       ` Dan Williams
@ 2021-10-26  1:42         ` Dan Williams
  2021-10-26  5:53           ` Christoph Hellwig
  0 siblings, 1 reply; 14+ messages in thread
From: Dan Williams @ 2021-10-26  1:42 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Adam Borowski, Vishal Verma, Dave Jiang, Ira Weiny, Jens Axboe,
	Yi Zhang, linux-block, Linux NVDIMM, Linux MM

On Fri, Oct 22, 2021 at 8:43 AM Dan Williams <dan.j.williams@intel.com> wrote:
>
> On Thu, Oct 21, 2021 at 10:55 PM Christoph Hellwig <hch@lst.de> wrote:
> >
> > On Thu, Oct 21, 2021 at 03:40:17PM +0200, Adam Borowski wrote:
> > > This breaks at least drivers/pci/p2pdma.c:222
> >
> > Indeed.  I've updated this patch, but the fix we need to urgently
> > get into 5.15-rc is the first one only anyway.
> >
> > nvdimm maintainers, can you please act on it ASAP?
>
> Yes, I have been pulled in many directions this past week, but I do
> plan to get this queued for v5.15-rc7.

Ok, this is passing all my tests and will be pushed out to -next tonight.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/2] memremap: remove support for external pgmap refcounts
  2021-10-26  1:42         ` Dan Williams
@ 2021-10-26  5:53           ` Christoph Hellwig
  2021-10-26 17:34             ` Dan Williams
  0 siblings, 1 reply; 14+ messages in thread
From: Christoph Hellwig @ 2021-10-26  5:53 UTC (permalink / raw)
  To: Dan Williams
  Cc: Christoph Hellwig, Adam Borowski, Vishal Verma, Dave Jiang,
	Ira Weiny, Jens Axboe, Yi Zhang, linux-block, Linux NVDIMM,
	Linux MM

On Mon, Oct 25, 2021 at 06:42:51PM -0700, Dan Williams wrote:
> On Fri, Oct 22, 2021 at 8:43 AM Dan Williams <dan.j.williams@intel.com> wrote:
> >
> > On Thu, Oct 21, 2021 at 10:55 PM Christoph Hellwig <hch@lst.de> wrote:
> > >
> > > On Thu, Oct 21, 2021 at 03:40:17PM +0200, Adam Borowski wrote:
> > > > This breaks at least drivers/pci/p2pdma.c:222
> > >
> > > Indeed.  I've updated this patch, but the fix we need to urgently
> > > get into 5.15-rc is the first one only anyway.
> > >
> > > nvdimm maintainers, can you please act on it ASAP?
> >
> > Yes, I have been pulled in many directions this past week, but I do
> > plan to get this queued for v5.15-rc7.
> 
> Ok, this is passing all my tests and will be pushed out to -next tonight.

FYI, patch 2 needs a trivial compile fix for the p2p case.  But I suspect
given how late in the cycle we are you're only picking up patch 1 anyway.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/2] memremap: remove support for external pgmap refcounts
  2021-10-26  5:53           ` Christoph Hellwig
@ 2021-10-26 17:34             ` Dan Williams
  0 siblings, 0 replies; 14+ messages in thread
From: Dan Williams @ 2021-10-26 17:34 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Adam Borowski, Vishal Verma, Dave Jiang, Ira Weiny, Jens Axboe,
	Yi Zhang, linux-block, Linux NVDIMM, Linux MM

On Mon, Oct 25, 2021 at 10:54 PM Christoph Hellwig <hch@lst.de> wrote:
>
> On Mon, Oct 25, 2021 at 06:42:51PM -0700, Dan Williams wrote:
> > On Fri, Oct 22, 2021 at 8:43 AM Dan Williams <dan.j.williams@intel.com> wrote:
> > >
> > > On Thu, Oct 21, 2021 at 10:55 PM Christoph Hellwig <hch@lst.de> wrote:
> > > >
> > > > On Thu, Oct 21, 2021 at 03:40:17PM +0200, Adam Borowski wrote:
> > > > > This breaks at least drivers/pci/p2pdma.c:222
> > > >
> > > > Indeed.  I've updated this patch, but the fix we need to urgently
> > > > get into 5.15-rc is the first one only anyway.
> > > >
> > > > nvdimm maintainers, can you please act on it ASAP?
> > >
> > > Yes, I have been pulled in many directions this past week, but I do
> > > plan to get this queued for v5.15-rc7.
> >
> > Ok, this is passing all my tests and will be pushed out to -next tonight.
>
> FYI, patch 2 needs a trivial compile fix for the p2p case.  But I suspect
> given how late in the cycle we are you're only picking up patch 1 anyway.

Yeah, patch1 I'll push for v5.15-final and patch2 for v5.16-rc1. Send
me that fixed up patch and I'll queue it up.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/2] memremap: remove support for external pgmap refcounts
  2021-10-19  7:36 ` [PATCH 2/2] memremap: remove support for external pgmap refcounts Christoph Hellwig
@ 2021-11-06  5:35     ` kernel test robot
  2021-11-06  5:35     ` kernel test robot
  2021-11-14  0:13   ` kernel test robot
  2 siblings, 0 replies; 14+ messages in thread
From: kernel test robot @ 2021-11-06  5:35 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: llvm, kbuild-all

[-- Attachment #1: Type: text/plain, Size: 8143 bytes --]

Hi Christoph,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on nvdimm/libnvdimm-for-next]
[cannot apply to hnaz-mm/master v5.15 next-20211106]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Christoph-Hellwig/nvdimm-pmem-stop-using-q_usage_count-as-external-pgmap-refcount/20211019-163725
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 519d81956ee277b4419c723adfb154603c2565ba
config: x86_64-randconfig-a002-20211019 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project b37efed957ed0a0193d80020aefd55cb587dfc1f)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/52278e5e6fc46f4d71f00c7e068331769b456d19
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Christoph-Hellwig/nvdimm-pmem-stop-using-q_usage_count-as-external-pgmap-refcount/20211019-163725
        git checkout 52278e5e6fc46f4d71f00c7e068331769b456d19
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/pci/p2pdma.c:222:4: error: passing 'struct percpu_ref' to parameter of incompatible type 'void *'
                           pgmap->ref);
                           ^~~~~~~~~~
   include/linux/genalloc.h:99:28: note: passing argument to parameter here
                                size_t, int, void *);
                                                   ^
   1 error generated.


vim +222 drivers/pci/p2pdma.c

52916982af48d9 Logan Gunthorpe   2018-10-04  160  
52916982af48d9 Logan Gunthorpe   2018-10-04  161  /**
52916982af48d9 Logan Gunthorpe   2018-10-04  162   * pci_p2pdma_add_resource - add memory for use as p2p memory
52916982af48d9 Logan Gunthorpe   2018-10-04  163   * @pdev: the device to add the memory to
52916982af48d9 Logan Gunthorpe   2018-10-04  164   * @bar: PCI BAR to add
52916982af48d9 Logan Gunthorpe   2018-10-04  165   * @size: size of the memory to add, may be zero to use the whole BAR
52916982af48d9 Logan Gunthorpe   2018-10-04  166   * @offset: offset into the PCI BAR
52916982af48d9 Logan Gunthorpe   2018-10-04  167   *
52916982af48d9 Logan Gunthorpe   2018-10-04  168   * The memory will be given ZONE_DEVICE struct pages so that it may
52916982af48d9 Logan Gunthorpe   2018-10-04  169   * be used with any DMA request.
52916982af48d9 Logan Gunthorpe   2018-10-04  170   */
52916982af48d9 Logan Gunthorpe   2018-10-04  171  int pci_p2pdma_add_resource(struct pci_dev *pdev, int bar, size_t size,
52916982af48d9 Logan Gunthorpe   2018-10-04  172  			    u64 offset)
52916982af48d9 Logan Gunthorpe   2018-10-04  173  {
a6e6fe6549f609 Logan Gunthorpe   2019-08-12  174  	struct pci_p2pdma_pagemap *p2p_pgmap;
52916982af48d9 Logan Gunthorpe   2018-10-04  175  	struct dev_pagemap *pgmap;
ae21f835a5bda0 Eric Dumazet      2021-07-01  176  	struct pci_p2pdma *p2pdma;
52916982af48d9 Logan Gunthorpe   2018-10-04  177  	void *addr;
52916982af48d9 Logan Gunthorpe   2018-10-04  178  	int error;
52916982af48d9 Logan Gunthorpe   2018-10-04  179  
52916982af48d9 Logan Gunthorpe   2018-10-04  180  	if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM))
52916982af48d9 Logan Gunthorpe   2018-10-04  181  		return -EINVAL;
52916982af48d9 Logan Gunthorpe   2018-10-04  182  
52916982af48d9 Logan Gunthorpe   2018-10-04  183  	if (offset >= pci_resource_len(pdev, bar))
52916982af48d9 Logan Gunthorpe   2018-10-04  184  		return -EINVAL;
52916982af48d9 Logan Gunthorpe   2018-10-04  185  
52916982af48d9 Logan Gunthorpe   2018-10-04  186  	if (!size)
52916982af48d9 Logan Gunthorpe   2018-10-04  187  		size = pci_resource_len(pdev, bar) - offset;
52916982af48d9 Logan Gunthorpe   2018-10-04  188  
52916982af48d9 Logan Gunthorpe   2018-10-04  189  	if (size + offset > pci_resource_len(pdev, bar))
52916982af48d9 Logan Gunthorpe   2018-10-04  190  		return -EINVAL;
52916982af48d9 Logan Gunthorpe   2018-10-04  191  
52916982af48d9 Logan Gunthorpe   2018-10-04  192  	if (!pdev->p2pdma) {
52916982af48d9 Logan Gunthorpe   2018-10-04  193  		error = pci_p2pdma_setup(pdev);
52916982af48d9 Logan Gunthorpe   2018-10-04  194  		if (error)
52916982af48d9 Logan Gunthorpe   2018-10-04  195  			return error;
52916982af48d9 Logan Gunthorpe   2018-10-04  196  	}
52916982af48d9 Logan Gunthorpe   2018-10-04  197  
a6e6fe6549f609 Logan Gunthorpe   2019-08-12  198  	p2p_pgmap = devm_kzalloc(&pdev->dev, sizeof(*p2p_pgmap), GFP_KERNEL);
a6e6fe6549f609 Logan Gunthorpe   2019-08-12  199  	if (!p2p_pgmap)
52916982af48d9 Logan Gunthorpe   2018-10-04  200  		return -ENOMEM;
a6e6fe6549f609 Logan Gunthorpe   2019-08-12  201  
a6e6fe6549f609 Logan Gunthorpe   2019-08-12  202  	pgmap = &p2p_pgmap->pgmap;
a4574f63edc6f7 Dan Williams      2020-10-13  203  	pgmap->range.start = pci_resource_start(pdev, bar) + offset;
a4574f63edc6f7 Dan Williams      2020-10-13  204  	pgmap->range.end = pgmap->range.start + size - 1;
b7b3c01b191596 Dan Williams      2020-10-13  205  	pgmap->nr_range = 1;
52916982af48d9 Logan Gunthorpe   2018-10-04  206  	pgmap->type = MEMORY_DEVICE_PCI_P2PDMA;
a6e6fe6549f609 Logan Gunthorpe   2019-08-12  207  
0afea3814358c9 Logan Gunthorpe   2019-08-12  208  	p2p_pgmap->provider = pdev;
a6e6fe6549f609 Logan Gunthorpe   2019-08-12  209  	p2p_pgmap->bus_offset = pci_bus_address(pdev, bar) -
977196b8c5b20b Logan Gunthorpe   2018-10-04  210  		pci_resource_start(pdev, bar);
52916982af48d9 Logan Gunthorpe   2018-10-04  211  
52916982af48d9 Logan Gunthorpe   2018-10-04  212  	addr = devm_memremap_pages(&pdev->dev, pgmap);
52916982af48d9 Logan Gunthorpe   2018-10-04  213  	if (IS_ERR(addr)) {
52916982af48d9 Logan Gunthorpe   2018-10-04  214  		error = PTR_ERR(addr);
50f44ee7248ad2 Dan Williams      2019-06-13  215  		goto pgmap_free;
52916982af48d9 Logan Gunthorpe   2018-10-04  216  	}
52916982af48d9 Logan Gunthorpe   2018-10-04  217  
ae21f835a5bda0 Eric Dumazet      2021-07-01  218  	p2pdma = rcu_dereference_protected(pdev->p2pdma, 1);
ae21f835a5bda0 Eric Dumazet      2021-07-01  219  	error = gen_pool_add_owner(p2pdma->pool, (unsigned long)addr,
52916982af48d9 Logan Gunthorpe   2018-10-04  220  			pci_bus_address(pdev, bar) + offset,
a4574f63edc6f7 Dan Williams      2020-10-13  221  			range_len(&pgmap->range), dev_to_node(&pdev->dev),
d0b3517dbcf3f6 Christoph Hellwig 2019-06-26 @222  			pgmap->ref);
52916982af48d9 Logan Gunthorpe   2018-10-04  223  	if (error)
e615a191216e3f Dan Williams      2019-06-13  224  		goto pages_free;
52916982af48d9 Logan Gunthorpe   2018-10-04  225  
a4574f63edc6f7 Dan Williams      2020-10-13  226  	pci_info(pdev, "added peer-to-peer DMA memory %#llx-%#llx\n",
a4574f63edc6f7 Dan Williams      2020-10-13  227  		 pgmap->range.start, pgmap->range.end);
52916982af48d9 Logan Gunthorpe   2018-10-04  228  
52916982af48d9 Logan Gunthorpe   2018-10-04  229  	return 0;
52916982af48d9 Logan Gunthorpe   2018-10-04  230  
e615a191216e3f Dan Williams      2019-06-13  231  pages_free:
e615a191216e3f Dan Williams      2019-06-13  232  	devm_memunmap_pages(&pdev->dev, pgmap);
52916982af48d9 Logan Gunthorpe   2018-10-04  233  pgmap_free:
d0b3517dbcf3f6 Christoph Hellwig 2019-06-26  234  	devm_kfree(&pdev->dev, pgmap);
52916982af48d9 Logan Gunthorpe   2018-10-04  235  	return error;
52916982af48d9 Logan Gunthorpe   2018-10-04  236  }
52916982af48d9 Logan Gunthorpe   2018-10-04  237  EXPORT_SYMBOL_GPL(pci_p2pdma_add_resource);
52916982af48d9 Logan Gunthorpe   2018-10-04  238  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 33166 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/2] memremap: remove support for external pgmap refcounts
@ 2021-11-06  5:35     ` kernel test robot
  0 siblings, 0 replies; 14+ messages in thread
From: kernel test robot @ 2021-11-06  5:35 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 8269 bytes --]

Hi Christoph,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on nvdimm/libnvdimm-for-next]
[cannot apply to hnaz-mm/master v5.15 next-20211106]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Christoph-Hellwig/nvdimm-pmem-stop-using-q_usage_count-as-external-pgmap-refcount/20211019-163725
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 519d81956ee277b4419c723adfb154603c2565ba
config: x86_64-randconfig-a002-20211019 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project b37efed957ed0a0193d80020aefd55cb587dfc1f)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/52278e5e6fc46f4d71f00c7e068331769b456d19
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Christoph-Hellwig/nvdimm-pmem-stop-using-q_usage_count-as-external-pgmap-refcount/20211019-163725
        git checkout 52278e5e6fc46f4d71f00c7e068331769b456d19
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/pci/p2pdma.c:222:4: error: passing 'struct percpu_ref' to parameter of incompatible type 'void *'
                           pgmap->ref);
                           ^~~~~~~~~~
   include/linux/genalloc.h:99:28: note: passing argument to parameter here
                                size_t, int, void *);
                                                   ^
   1 error generated.


vim +222 drivers/pci/p2pdma.c

52916982af48d9 Logan Gunthorpe   2018-10-04  160  
52916982af48d9 Logan Gunthorpe   2018-10-04  161  /**
52916982af48d9 Logan Gunthorpe   2018-10-04  162   * pci_p2pdma_add_resource - add memory for use as p2p memory
52916982af48d9 Logan Gunthorpe   2018-10-04  163   * @pdev: the device to add the memory to
52916982af48d9 Logan Gunthorpe   2018-10-04  164   * @bar: PCI BAR to add
52916982af48d9 Logan Gunthorpe   2018-10-04  165   * @size: size of the memory to add, may be zero to use the whole BAR
52916982af48d9 Logan Gunthorpe   2018-10-04  166   * @offset: offset into the PCI BAR
52916982af48d9 Logan Gunthorpe   2018-10-04  167   *
52916982af48d9 Logan Gunthorpe   2018-10-04  168   * The memory will be given ZONE_DEVICE struct pages so that it may
52916982af48d9 Logan Gunthorpe   2018-10-04  169   * be used with any DMA request.
52916982af48d9 Logan Gunthorpe   2018-10-04  170   */
52916982af48d9 Logan Gunthorpe   2018-10-04  171  int pci_p2pdma_add_resource(struct pci_dev *pdev, int bar, size_t size,
52916982af48d9 Logan Gunthorpe   2018-10-04  172  			    u64 offset)
52916982af48d9 Logan Gunthorpe   2018-10-04  173  {
a6e6fe6549f609 Logan Gunthorpe   2019-08-12  174  	struct pci_p2pdma_pagemap *p2p_pgmap;
52916982af48d9 Logan Gunthorpe   2018-10-04  175  	struct dev_pagemap *pgmap;
ae21f835a5bda0 Eric Dumazet      2021-07-01  176  	struct pci_p2pdma *p2pdma;
52916982af48d9 Logan Gunthorpe   2018-10-04  177  	void *addr;
52916982af48d9 Logan Gunthorpe   2018-10-04  178  	int error;
52916982af48d9 Logan Gunthorpe   2018-10-04  179  
52916982af48d9 Logan Gunthorpe   2018-10-04  180  	if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM))
52916982af48d9 Logan Gunthorpe   2018-10-04  181  		return -EINVAL;
52916982af48d9 Logan Gunthorpe   2018-10-04  182  
52916982af48d9 Logan Gunthorpe   2018-10-04  183  	if (offset >= pci_resource_len(pdev, bar))
52916982af48d9 Logan Gunthorpe   2018-10-04  184  		return -EINVAL;
52916982af48d9 Logan Gunthorpe   2018-10-04  185  
52916982af48d9 Logan Gunthorpe   2018-10-04  186  	if (!size)
52916982af48d9 Logan Gunthorpe   2018-10-04  187  		size = pci_resource_len(pdev, bar) - offset;
52916982af48d9 Logan Gunthorpe   2018-10-04  188  
52916982af48d9 Logan Gunthorpe   2018-10-04  189  	if (size + offset > pci_resource_len(pdev, bar))
52916982af48d9 Logan Gunthorpe   2018-10-04  190  		return -EINVAL;
52916982af48d9 Logan Gunthorpe   2018-10-04  191  
52916982af48d9 Logan Gunthorpe   2018-10-04  192  	if (!pdev->p2pdma) {
52916982af48d9 Logan Gunthorpe   2018-10-04  193  		error = pci_p2pdma_setup(pdev);
52916982af48d9 Logan Gunthorpe   2018-10-04  194  		if (error)
52916982af48d9 Logan Gunthorpe   2018-10-04  195  			return error;
52916982af48d9 Logan Gunthorpe   2018-10-04  196  	}
52916982af48d9 Logan Gunthorpe   2018-10-04  197  
a6e6fe6549f609 Logan Gunthorpe   2019-08-12  198  	p2p_pgmap = devm_kzalloc(&pdev->dev, sizeof(*p2p_pgmap), GFP_KERNEL);
a6e6fe6549f609 Logan Gunthorpe   2019-08-12  199  	if (!p2p_pgmap)
52916982af48d9 Logan Gunthorpe   2018-10-04  200  		return -ENOMEM;
a6e6fe6549f609 Logan Gunthorpe   2019-08-12  201  
a6e6fe6549f609 Logan Gunthorpe   2019-08-12  202  	pgmap = &p2p_pgmap->pgmap;
a4574f63edc6f7 Dan Williams      2020-10-13  203  	pgmap->range.start = pci_resource_start(pdev, bar) + offset;
a4574f63edc6f7 Dan Williams      2020-10-13  204  	pgmap->range.end = pgmap->range.start + size - 1;
b7b3c01b191596 Dan Williams      2020-10-13  205  	pgmap->nr_range = 1;
52916982af48d9 Logan Gunthorpe   2018-10-04  206  	pgmap->type = MEMORY_DEVICE_PCI_P2PDMA;
a6e6fe6549f609 Logan Gunthorpe   2019-08-12  207  
0afea3814358c9 Logan Gunthorpe   2019-08-12  208  	p2p_pgmap->provider = pdev;
a6e6fe6549f609 Logan Gunthorpe   2019-08-12  209  	p2p_pgmap->bus_offset = pci_bus_address(pdev, bar) -
977196b8c5b20b Logan Gunthorpe   2018-10-04  210  		pci_resource_start(pdev, bar);
52916982af48d9 Logan Gunthorpe   2018-10-04  211  
52916982af48d9 Logan Gunthorpe   2018-10-04  212  	addr = devm_memremap_pages(&pdev->dev, pgmap);
52916982af48d9 Logan Gunthorpe   2018-10-04  213  	if (IS_ERR(addr)) {
52916982af48d9 Logan Gunthorpe   2018-10-04  214  		error = PTR_ERR(addr);
50f44ee7248ad2 Dan Williams      2019-06-13  215  		goto pgmap_free;
52916982af48d9 Logan Gunthorpe   2018-10-04  216  	}
52916982af48d9 Logan Gunthorpe   2018-10-04  217  
ae21f835a5bda0 Eric Dumazet      2021-07-01  218  	p2pdma = rcu_dereference_protected(pdev->p2pdma, 1);
ae21f835a5bda0 Eric Dumazet      2021-07-01  219  	error = gen_pool_add_owner(p2pdma->pool, (unsigned long)addr,
52916982af48d9 Logan Gunthorpe   2018-10-04  220  			pci_bus_address(pdev, bar) + offset,
a4574f63edc6f7 Dan Williams      2020-10-13  221  			range_len(&pgmap->range), dev_to_node(&pdev->dev),
d0b3517dbcf3f6 Christoph Hellwig 2019-06-26 @222  			pgmap->ref);
52916982af48d9 Logan Gunthorpe   2018-10-04  223  	if (error)
e615a191216e3f Dan Williams      2019-06-13  224  		goto pages_free;
52916982af48d9 Logan Gunthorpe   2018-10-04  225  
a4574f63edc6f7 Dan Williams      2020-10-13  226  	pci_info(pdev, "added peer-to-peer DMA memory %#llx-%#llx\n",
a4574f63edc6f7 Dan Williams      2020-10-13  227  		 pgmap->range.start, pgmap->range.end);
52916982af48d9 Logan Gunthorpe   2018-10-04  228  
52916982af48d9 Logan Gunthorpe   2018-10-04  229  	return 0;
52916982af48d9 Logan Gunthorpe   2018-10-04  230  
e615a191216e3f Dan Williams      2019-06-13  231  pages_free:
e615a191216e3f Dan Williams      2019-06-13  232  	devm_memunmap_pages(&pdev->dev, pgmap);
52916982af48d9 Logan Gunthorpe   2018-10-04  233  pgmap_free:
d0b3517dbcf3f6 Christoph Hellwig 2019-06-26  234  	devm_kfree(&pdev->dev, pgmap);
52916982af48d9 Logan Gunthorpe   2018-10-04  235  	return error;
52916982af48d9 Logan Gunthorpe   2018-10-04  236  }
52916982af48d9 Logan Gunthorpe   2018-10-04  237  EXPORT_SYMBOL_GPL(pci_p2pdma_add_resource);
52916982af48d9 Logan Gunthorpe   2018-10-04  238  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 33166 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/2] memremap: remove support for external pgmap refcounts
  2021-10-19  7:36 ` [PATCH 2/2] memremap: remove support for external pgmap refcounts Christoph Hellwig
  2021-10-21 13:40   ` Adam Borowski
  2021-11-06  5:35     ` kernel test robot
@ 2021-11-14  0:13   ` kernel test robot
  2 siblings, 0 replies; 14+ messages in thread
From: kernel test robot @ 2021-11-14  0:13 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 8176 bytes --]

Hi Christoph,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on nvdimm/libnvdimm-for-next]
[cannot apply to hnaz-mm/master v5.15 next-20211112]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Christoph-Hellwig/nvdimm-pmem-stop-using-q_usage_count-as-external-pgmap-refcount/20211019-163725
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 519d81956ee277b4419c723adfb154603c2565ba
config: x86_64-allyesconfig (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/52278e5e6fc46f4d71f00c7e068331769b456d19
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Christoph-Hellwig/nvdimm-pmem-stop-using-q_usage_count-as-external-pgmap-refcount/20211019-163725
        git checkout 52278e5e6fc46f4d71f00c7e068331769b456d19
        # save the attached .config to linux build tree
        mkdir build_dir
        make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/pci/p2pdma.c: In function 'pci_p2pdma_add_resource':
>> drivers/pci/p2pdma.c:222:9: error: incompatible type for argument 6 of 'gen_pool_add_owner'
     222 |    pgmap->ref);
         |    ~~~~~^~~~~
         |         |
         |         struct percpu_ref
   In file included from drivers/pci/p2pdma.c:16:
   include/linux/genalloc.h:99:22: note: expected 'void *' but argument is of type 'struct percpu_ref'
      99 |         size_t, int, void *);
         |                      ^~~~~~


vim +/gen_pool_add_owner +222 drivers/pci/p2pdma.c

52916982af48d9 Logan Gunthorpe   2018-10-04  160  
52916982af48d9 Logan Gunthorpe   2018-10-04  161  /**
52916982af48d9 Logan Gunthorpe   2018-10-04  162   * pci_p2pdma_add_resource - add memory for use as p2p memory
52916982af48d9 Logan Gunthorpe   2018-10-04  163   * @pdev: the device to add the memory to
52916982af48d9 Logan Gunthorpe   2018-10-04  164   * @bar: PCI BAR to add
52916982af48d9 Logan Gunthorpe   2018-10-04  165   * @size: size of the memory to add, may be zero to use the whole BAR
52916982af48d9 Logan Gunthorpe   2018-10-04  166   * @offset: offset into the PCI BAR
52916982af48d9 Logan Gunthorpe   2018-10-04  167   *
52916982af48d9 Logan Gunthorpe   2018-10-04  168   * The memory will be given ZONE_DEVICE struct pages so that it may
52916982af48d9 Logan Gunthorpe   2018-10-04  169   * be used with any DMA request.
52916982af48d9 Logan Gunthorpe   2018-10-04  170   */
52916982af48d9 Logan Gunthorpe   2018-10-04  171  int pci_p2pdma_add_resource(struct pci_dev *pdev, int bar, size_t size,
52916982af48d9 Logan Gunthorpe   2018-10-04  172  			    u64 offset)
52916982af48d9 Logan Gunthorpe   2018-10-04  173  {
a6e6fe6549f609 Logan Gunthorpe   2019-08-12  174  	struct pci_p2pdma_pagemap *p2p_pgmap;
52916982af48d9 Logan Gunthorpe   2018-10-04  175  	struct dev_pagemap *pgmap;
ae21f835a5bda0 Eric Dumazet      2021-07-01  176  	struct pci_p2pdma *p2pdma;
52916982af48d9 Logan Gunthorpe   2018-10-04  177  	void *addr;
52916982af48d9 Logan Gunthorpe   2018-10-04  178  	int error;
52916982af48d9 Logan Gunthorpe   2018-10-04  179  
52916982af48d9 Logan Gunthorpe   2018-10-04  180  	if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM))
52916982af48d9 Logan Gunthorpe   2018-10-04  181  		return -EINVAL;
52916982af48d9 Logan Gunthorpe   2018-10-04  182  
52916982af48d9 Logan Gunthorpe   2018-10-04  183  	if (offset >= pci_resource_len(pdev, bar))
52916982af48d9 Logan Gunthorpe   2018-10-04  184  		return -EINVAL;
52916982af48d9 Logan Gunthorpe   2018-10-04  185  
52916982af48d9 Logan Gunthorpe   2018-10-04  186  	if (!size)
52916982af48d9 Logan Gunthorpe   2018-10-04  187  		size = pci_resource_len(pdev, bar) - offset;
52916982af48d9 Logan Gunthorpe   2018-10-04  188  
52916982af48d9 Logan Gunthorpe   2018-10-04  189  	if (size + offset > pci_resource_len(pdev, bar))
52916982af48d9 Logan Gunthorpe   2018-10-04  190  		return -EINVAL;
52916982af48d9 Logan Gunthorpe   2018-10-04  191  
52916982af48d9 Logan Gunthorpe   2018-10-04  192  	if (!pdev->p2pdma) {
52916982af48d9 Logan Gunthorpe   2018-10-04  193  		error = pci_p2pdma_setup(pdev);
52916982af48d9 Logan Gunthorpe   2018-10-04  194  		if (error)
52916982af48d9 Logan Gunthorpe   2018-10-04  195  			return error;
52916982af48d9 Logan Gunthorpe   2018-10-04  196  	}
52916982af48d9 Logan Gunthorpe   2018-10-04  197  
a6e6fe6549f609 Logan Gunthorpe   2019-08-12  198  	p2p_pgmap = devm_kzalloc(&pdev->dev, sizeof(*p2p_pgmap), GFP_KERNEL);
a6e6fe6549f609 Logan Gunthorpe   2019-08-12  199  	if (!p2p_pgmap)
52916982af48d9 Logan Gunthorpe   2018-10-04  200  		return -ENOMEM;
a6e6fe6549f609 Logan Gunthorpe   2019-08-12  201  
a6e6fe6549f609 Logan Gunthorpe   2019-08-12  202  	pgmap = &p2p_pgmap->pgmap;
a4574f63edc6f7 Dan Williams      2020-10-13  203  	pgmap->range.start = pci_resource_start(pdev, bar) + offset;
a4574f63edc6f7 Dan Williams      2020-10-13  204  	pgmap->range.end = pgmap->range.start + size - 1;
b7b3c01b191596 Dan Williams      2020-10-13  205  	pgmap->nr_range = 1;
52916982af48d9 Logan Gunthorpe   2018-10-04  206  	pgmap->type = MEMORY_DEVICE_PCI_P2PDMA;
a6e6fe6549f609 Logan Gunthorpe   2019-08-12  207  
0afea3814358c9 Logan Gunthorpe   2019-08-12  208  	p2p_pgmap->provider = pdev;
a6e6fe6549f609 Logan Gunthorpe   2019-08-12  209  	p2p_pgmap->bus_offset = pci_bus_address(pdev, bar) -
977196b8c5b20b Logan Gunthorpe   2018-10-04  210  		pci_resource_start(pdev, bar);
52916982af48d9 Logan Gunthorpe   2018-10-04  211  
52916982af48d9 Logan Gunthorpe   2018-10-04  212  	addr = devm_memremap_pages(&pdev->dev, pgmap);
52916982af48d9 Logan Gunthorpe   2018-10-04  213  	if (IS_ERR(addr)) {
52916982af48d9 Logan Gunthorpe   2018-10-04  214  		error = PTR_ERR(addr);
50f44ee7248ad2 Dan Williams      2019-06-13  215  		goto pgmap_free;
52916982af48d9 Logan Gunthorpe   2018-10-04  216  	}
52916982af48d9 Logan Gunthorpe   2018-10-04  217  
ae21f835a5bda0 Eric Dumazet      2021-07-01  218  	p2pdma = rcu_dereference_protected(pdev->p2pdma, 1);
ae21f835a5bda0 Eric Dumazet      2021-07-01  219  	error = gen_pool_add_owner(p2pdma->pool, (unsigned long)addr,
52916982af48d9 Logan Gunthorpe   2018-10-04  220  			pci_bus_address(pdev, bar) + offset,
a4574f63edc6f7 Dan Williams      2020-10-13  221  			range_len(&pgmap->range), dev_to_node(&pdev->dev),
d0b3517dbcf3f6 Christoph Hellwig 2019-06-26 @222  			pgmap->ref);
52916982af48d9 Logan Gunthorpe   2018-10-04  223  	if (error)
e615a191216e3f Dan Williams      2019-06-13  224  		goto pages_free;
52916982af48d9 Logan Gunthorpe   2018-10-04  225  
a4574f63edc6f7 Dan Williams      2020-10-13  226  	pci_info(pdev, "added peer-to-peer DMA memory %#llx-%#llx\n",
a4574f63edc6f7 Dan Williams      2020-10-13  227  		 pgmap->range.start, pgmap->range.end);
52916982af48d9 Logan Gunthorpe   2018-10-04  228  
52916982af48d9 Logan Gunthorpe   2018-10-04  229  	return 0;
52916982af48d9 Logan Gunthorpe   2018-10-04  230  
e615a191216e3f Dan Williams      2019-06-13  231  pages_free:
e615a191216e3f Dan Williams      2019-06-13  232  	devm_memunmap_pages(&pdev->dev, pgmap);
52916982af48d9 Logan Gunthorpe   2018-10-04  233  pgmap_free:
d0b3517dbcf3f6 Christoph Hellwig 2019-06-26  234  	devm_kfree(&pdev->dev, pgmap);
52916982af48d9 Logan Gunthorpe   2018-10-04  235  	return error;
52916982af48d9 Logan Gunthorpe   2018-10-04  236  }
52916982af48d9 Logan Gunthorpe   2018-10-04  237  EXPORT_SYMBOL_GPL(pci_p2pdma_add_resource);
52916982af48d9 Logan Gunthorpe   2018-10-04  238  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 64945 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-11-14  0:13 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-19  7:36 fix a pmem regression due to drain the block queue in del_gendisk Christoph Hellwig
2021-10-19  7:36 ` [PATCH 1/2] nvdimm/pmem: stop using q_usage_count as external pgmap refcount Christoph Hellwig
2021-10-19  7:36 ` [PATCH 2/2] memremap: remove support for external pgmap refcounts Christoph Hellwig
2021-10-21 13:40   ` Adam Borowski
2021-10-22  5:55     ` Christoph Hellwig
2021-10-22  8:52       ` Adam Borowski
2021-10-22 15:43       ` Dan Williams
2021-10-26  1:42         ` Dan Williams
2021-10-26  5:53           ` Christoph Hellwig
2021-10-26 17:34             ` Dan Williams
2021-11-06  5:35   ` kernel test robot
2021-11-06  5:35     ` kernel test robot
2021-11-14  0:13   ` kernel test robot
2021-10-20  6:38 ` fix a pmem regression due to drain the block queue in del_gendisk Yi Zhang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.