linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: kill is_memblock_offlined()
@ 2022-08-27 11:20 Kefeng Wang
  2022-08-30 10:48 ` David Hildenbrand
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Kefeng Wang @ 2022-08-27 11:20 UTC (permalink / raw)
  To: David Hildenbrand, Oscar Salvador, Andrew Morton
  Cc: linux-mm, linux-kernel, Kefeng Wang

Directly check state of struct memory_block, no need a single function.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 drivers/base/memory.c          | 6 ------
 include/linux/memory_hotplug.h | 2 --
 mm/memory_hotplug.c            | 3 +--
 3 files changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index bc60c9cd3230..9aa0da991cfb 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -869,12 +869,6 @@ void remove_memory_block_devices(unsigned long start, unsigned long size)
 	}
 }
 
-/* return true if the memory block is offlined, otherwise, return false */
-bool is_memblock_offlined(struct memory_block *mem)
-{
-	return mem->state == MEM_OFFLINE;
-}
-
 static struct attribute *memory_root_attrs[] = {
 #ifdef CONFIG_ARCH_MEMORY_PROBE
 	&dev_attr_probe.attr,
diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
index 409196ef8038..de87545eabe9 100644
--- a/include/linux/memory_hotplug.h
+++ b/include/linux/memory_hotplug.h
@@ -11,7 +11,6 @@ struct page;
 struct zone;
 struct pglist_data;
 struct mem_section;
-struct memory_block;
 struct memory_group;
 struct resource;
 struct vmem_altmap;
@@ -352,7 +351,6 @@ extern void move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn,
 extern void remove_pfn_range_from_zone(struct zone *zone,
 				       unsigned long start_pfn,
 				       unsigned long nr_pages);
-extern bool is_memblock_offlined(struct memory_block *mem);
 extern int sparse_add_section(int nid, unsigned long pfn,
 		unsigned long nr_pages, struct vmem_altmap *altmap,
 		struct dev_pagemap *pgmap);
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 2fd45ccbce45..9ae1f98548b1 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1969,11 +1969,10 @@ int __ref offline_pages(unsigned long start_pfn, unsigned long nr_pages,
 
 static int check_memblock_offlined_cb(struct memory_block *mem, void *arg)
 {
-	int ret = !is_memblock_offlined(mem);
 	int *nid = arg;
 
 	*nid = mem->nid;
-	if (unlikely(ret)) {
+	if (unlikely(mem->state != MEM_OFFLINE)) {
 		phys_addr_t beginpa, endpa;
 
 		beginpa = PFN_PHYS(section_nr_to_pfn(mem->start_section_nr));
-- 
2.35.3


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

* Re: [PATCH] mm: kill is_memblock_offlined()
  2022-08-27 11:20 [PATCH] mm: kill is_memblock_offlined() Kefeng Wang
@ 2022-08-30 10:48 ` David Hildenbrand
  2022-08-31  5:06 ` Oscar Salvador
  2022-09-01  9:05 ` Anshuman Khandual
  2 siblings, 0 replies; 4+ messages in thread
From: David Hildenbrand @ 2022-08-30 10:48 UTC (permalink / raw)
  To: Kefeng Wang, Oscar Salvador, Andrew Morton; +Cc: linux-mm, linux-kernel

On 27.08.22 13:20, Kefeng Wang wrote:
> Directly check state of struct memory_block, no need a single function.
> 
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
>  drivers/base/memory.c          | 6 ------
>  include/linux/memory_hotplug.h | 2 --
>  mm/memory_hotplug.c            | 3 +--
>  3 files changed, 1 insertion(+), 10 deletions(-)
> 
> diff --git a/drivers/base/memory.c b/drivers/base/memory.c
> index bc60c9cd3230..9aa0da991cfb 100644
> --- a/drivers/base/memory.c
> +++ b/drivers/base/memory.c
> @@ -869,12 +869,6 @@ void remove_memory_block_devices(unsigned long start, unsigned long size)
>  	}
>  }
>  
> -/* return true if the memory block is offlined, otherwise, return false */
> -bool is_memblock_offlined(struct memory_block *mem)
> -{
> -	return mem->state == MEM_OFFLINE;
> -}
> -
>  static struct attribute *memory_root_attrs[] = {
>  #ifdef CONFIG_ARCH_MEMORY_PROBE
>  	&dev_attr_probe.attr,
> diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
> index 409196ef8038..de87545eabe9 100644
> --- a/include/linux/memory_hotplug.h
> +++ b/include/linux/memory_hotplug.h
> @@ -11,7 +11,6 @@ struct page;
>  struct zone;
>  struct pglist_data;
>  struct mem_section;
> -struct memory_block;
>  struct memory_group;
>  struct resource;
>  struct vmem_altmap;
> @@ -352,7 +351,6 @@ extern void move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn,
>  extern void remove_pfn_range_from_zone(struct zone *zone,
>  				       unsigned long start_pfn,
>  				       unsigned long nr_pages);
> -extern bool is_memblock_offlined(struct memory_block *mem);
>  extern int sparse_add_section(int nid, unsigned long pfn,
>  		unsigned long nr_pages, struct vmem_altmap *altmap,
>  		struct dev_pagemap *pgmap);
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index 2fd45ccbce45..9ae1f98548b1 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -1969,11 +1969,10 @@ int __ref offline_pages(unsigned long start_pfn, unsigned long nr_pages,
>  
>  static int check_memblock_offlined_cb(struct memory_block *mem, void *arg)
>  {
> -	int ret = !is_memblock_offlined(mem);
>  	int *nid = arg;
>  
>  	*nid = mem->nid;
> -	if (unlikely(ret)) {
> +	if (unlikely(mem->state != MEM_OFFLINE)) {
>  		phys_addr_t beginpa, endpa;
>  
>  		beginpa = PFN_PHYS(section_nr_to_pfn(mem->start_section_nr));

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Thanks,

David / dhildenb


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

* Re: [PATCH] mm: kill is_memblock_offlined()
  2022-08-27 11:20 [PATCH] mm: kill is_memblock_offlined() Kefeng Wang
  2022-08-30 10:48 ` David Hildenbrand
@ 2022-08-31  5:06 ` Oscar Salvador
  2022-09-01  9:05 ` Anshuman Khandual
  2 siblings, 0 replies; 4+ messages in thread
From: Oscar Salvador @ 2022-08-31  5:06 UTC (permalink / raw)
  To: Kefeng Wang; +Cc: David Hildenbrand, Andrew Morton, linux-mm, linux-kernel

On Sat, Aug 27, 2022 at 07:20:43PM +0800, Kefeng Wang wrote:
> Directly check state of struct memory_block, no need a single function.
> 
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>

Reviewed-by: Oscar Salvador <osalvador@suse.de>


-- 
Oscar Salvador
SUSE Labs

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

* Re: [PATCH] mm: kill is_memblock_offlined()
  2022-08-27 11:20 [PATCH] mm: kill is_memblock_offlined() Kefeng Wang
  2022-08-30 10:48 ` David Hildenbrand
  2022-08-31  5:06 ` Oscar Salvador
@ 2022-09-01  9:05 ` Anshuman Khandual
  2 siblings, 0 replies; 4+ messages in thread
From: Anshuman Khandual @ 2022-09-01  9:05 UTC (permalink / raw)
  To: Kefeng Wang, David Hildenbrand, Oscar Salvador, Andrew Morton
  Cc: linux-mm, linux-kernel



On 8/27/22 16:50, Kefeng Wang wrote:
> Directly check state of struct memory_block, no need a single function.
> 
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---

Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>

>  drivers/base/memory.c          | 6 ------
>  include/linux/memory_hotplug.h | 2 --
>  mm/memory_hotplug.c            | 3 +--
>  3 files changed, 1 insertion(+), 10 deletions(-)
> 
> diff --git a/drivers/base/memory.c b/drivers/base/memory.c
> index bc60c9cd3230..9aa0da991cfb 100644
> --- a/drivers/base/memory.c
> +++ b/drivers/base/memory.c
> @@ -869,12 +869,6 @@ void remove_memory_block_devices(unsigned long start, unsigned long size)
>  	}
>  }
>  
> -/* return true if the memory block is offlined, otherwise, return false */
> -bool is_memblock_offlined(struct memory_block *mem)
> -{
> -	return mem->state == MEM_OFFLINE;
> -}
> -
>  static struct attribute *memory_root_attrs[] = {
>  #ifdef CONFIG_ARCH_MEMORY_PROBE
>  	&dev_attr_probe.attr,
> diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
> index 409196ef8038..de87545eabe9 100644
> --- a/include/linux/memory_hotplug.h
> +++ b/include/linux/memory_hotplug.h
> @@ -11,7 +11,6 @@ struct page;
>  struct zone;
>  struct pglist_data;
>  struct mem_section;
> -struct memory_block;
>  struct memory_group;
>  struct resource;
>  struct vmem_altmap;
> @@ -352,7 +351,6 @@ extern void move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn,
>  extern void remove_pfn_range_from_zone(struct zone *zone,
>  				       unsigned long start_pfn,
>  				       unsigned long nr_pages);
> -extern bool is_memblock_offlined(struct memory_block *mem);
>  extern int sparse_add_section(int nid, unsigned long pfn,
>  		unsigned long nr_pages, struct vmem_altmap *altmap,
>  		struct dev_pagemap *pgmap);
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index 2fd45ccbce45..9ae1f98548b1 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -1969,11 +1969,10 @@ int __ref offline_pages(unsigned long start_pfn, unsigned long nr_pages,
>  
>  static int check_memblock_offlined_cb(struct memory_block *mem, void *arg)
>  {
> -	int ret = !is_memblock_offlined(mem);
>  	int *nid = arg;
>  
>  	*nid = mem->nid;
> -	if (unlikely(ret)) {
> +	if (unlikely(mem->state != MEM_OFFLINE)) {
>  		phys_addr_t beginpa, endpa;
>  
>  		beginpa = PFN_PHYS(section_nr_to_pfn(mem->start_section_nr));

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

end of thread, other threads:[~2022-09-01  9:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-27 11:20 [PATCH] mm: kill is_memblock_offlined() Kefeng Wang
2022-08-30 10:48 ` David Hildenbrand
2022-08-31  5:06 ` Oscar Salvador
2022-09-01  9:05 ` Anshuman Khandual

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).