Skip to content

Commit

Permalink
mm/sparsemem: cleanup 'section number' data types
Browse files Browse the repository at this point in the history
David points out that there is a mixture of 'int' and 'unsigned long'
usage for section number data types.  Update the memory hotplug path to
use 'unsigned long' consistently for section numbers.

[[email protected]: fix printk format]
Link: http://lkml.kernel.org/r/156107543656.1329419.11505835211949439815.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Dan Williams <[email protected]>
Reported-by: David Hildenbrand <[email protected]>
Reviewed-by: David Hildenbrand <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Oscar Salvador <[email protected]>
Cc: Jason Gunthorpe <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
djbw authored and torvalds committed Jul 19, 2019
1 parent a361919 commit 9a84503
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions mm/memory_hotplug.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ static int check_pfn_span(unsigned long pfn, unsigned long nr_pages,
int __ref __add_pages(int nid, unsigned long pfn, unsigned long nr_pages,
struct mhp_restrictions *restrictions)
{
unsigned long i;
int start_sec, end_sec, err;
int err;
unsigned long nr, start_sec, end_sec;
struct vmem_altmap *altmap = restrictions->altmap;

if (altmap) {
Expand All @@ -310,7 +310,7 @@ int __ref __add_pages(int nid, unsigned long pfn, unsigned long nr_pages,

start_sec = pfn_to_section_nr(pfn);
end_sec = pfn_to_section_nr(pfn + nr_pages - 1);
for (i = start_sec; i <= end_sec; i++) {
for (nr = start_sec; nr <= end_sec; nr++) {
unsigned long pfns;

pfns = min(nr_pages, PAGES_PER_SECTION
Expand Down Expand Up @@ -541,7 +541,7 @@ void __remove_pages(struct zone *zone, unsigned long pfn,
unsigned long nr_pages, struct vmem_altmap *altmap)
{
unsigned long map_offset = 0;
int i, start_sec, end_sec;
unsigned long nr, start_sec, end_sec;

map_offset = vmem_altmap_offset(altmap);

Expand All @@ -552,7 +552,7 @@ void __remove_pages(struct zone *zone, unsigned long pfn,

start_sec = pfn_to_section_nr(pfn);
end_sec = pfn_to_section_nr(pfn + nr_pages - 1);
for (i = start_sec; i <= end_sec; i++) {
for (nr = start_sec; nr <= end_sec; nr++) {
unsigned long pfns;

cond_resched();
Expand Down
8 changes: 4 additions & 4 deletions mm/sparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,21 +229,21 @@ void subsection_mask_set(unsigned long *map, unsigned long pfn,
void __init subsection_map_init(unsigned long pfn, unsigned long nr_pages)
{
int end_sec = pfn_to_section_nr(pfn + nr_pages - 1);
int i, start_sec = pfn_to_section_nr(pfn);
unsigned long nr, start_sec = pfn_to_section_nr(pfn);

if (!nr_pages)
return;

for (i = start_sec; i <= end_sec; i++) {
for (nr = start_sec; nr <= end_sec; nr++) {
struct mem_section *ms;
unsigned long pfns;

pfns = min(nr_pages, PAGES_PER_SECTION
- (pfn & ~PAGE_SECTION_MASK));
ms = __nr_to_section(i);
ms = __nr_to_section(nr);
subsection_mask_set(ms->usage->subsection_map, pfn, pfns);

pr_debug("%s: sec: %d pfns: %ld set(%d, %d)\n", __func__, i,
pr_debug("%s: sec: %lu pfns: %lu set(%d, %d)\n", __func__, nr,
pfns, subsection_map_index(pfn),
subsection_map_index(pfn + pfns - 1));

Expand Down

0 comments on commit 9a84503

Please sign in to comment.