2011-06-16 00:34:10

by Andrew Morton

[permalink] [raw]
Subject: mmotm 2011-06-15-16-56 uploaded

The mm-of-the-moment snapshot 2011-06-15-16-56 has been uploaded to

http://userweb.kernel.org/~akpm/mmotm/

and will soon be available at
git://zen-kernel.org/kernel/mmotm.git
or
git://git.cmpxchg.org/linux-mmotm.git

It contains the following patches against 3.0-rc3:

origin.patch
kbuild-call-depmodsh-via-shell.patch
mm-remove-khugepaged-double-thp-vmstat-update-with-config_numa=n.patch
mm-memoryc-fix-kernel-doc-notation.patch
lib-bitmapc-fix-kernel-doc-notation.patch
fs-execc-use-build_bug_on-for-vm_stack_flags-vm_stack_incomplete_setup.patch
backlight-new-driver-for-the-adp8870-backlight-devices.patch
backlight-add-backlight-type-fix.patch
vmscanmemcg-memcg-aware-swap-token.patch
vmscan-implement-swap-token-trace.patch
vmscan-implement-swap-token-priority-aging.patch
memcg-add-documentation-for-the-memorynumastat-api.patch
kmsg_dumph-fix-build-when-config_printk-is-disabled.patch
checkpatch-add-warning-for-uses-of-printk_ratelimit.patch
mm-increase-reclaim_distance-to-30.patch
drivers-misc-spear13xx_pcie_gadgetc-fix-a-memory-leak-in-spear_pcie_gadget_probe-error-path.patch
drivers-misc-cs5535-mfgptc-fix-wrong-if-condition.patch
mm-fix-wrong-kunmap_atomic-pointer.patch
mm-compaction-fix-special-case-1-order-checks.patch
mm-migratec-dont-account-swapcache-as-shmem.patch
build_bug_on_zero-fix-sparse-breakage.patch
uts-make-default-hostname-configurable-rather-than-always-using-none.patch
maintainers-balbir-has-moved.patch
drivers-leds-leds-asic3-make-leds_asic3-depend-on-leds_class.patch
leds-move-leds_gpio_register-out-of-menuconfig-new_leds.patch
maintainers-add-videobuf2-maintainers.patch
include-asm-generic-pgtableh-fix-unbalanced-parenthesis.patch
w1-w1_master_ds1wm-should-depend-on-generic_hardirqs.patch
init-calibratec-remove-annoying-printk.patch
mm-memory_hotplugc-fix-building-of-node-hotplug-zonelist.patch
mm-fix-negative-commitlimit-when-gigantic-hugepages-are-allocated.patch
leds-fix-the-menuconfig-being-wrongly-displayed.patch
mm-memorynuma_stat-fix-file-permission.patch
memcg-fix-init_page_cgroup-nid-with-sparsemem.patch
memcg-clear-mm-owner-when-last-possible-owner-leaves.patch
memcg-fix-wrong-check-of-noswap-with-softlimit.patch
memcg-fix-percpu-cached-charge-draining-frequency.patch
memcg-avoid-percpu-cached-charge-draining-at-softlimit.patch
maintainers-add-entry-for-legacy-eeprom-driver.patch
gcov-disable-config_constructors-when-not-needed-by-config_gcov_kernel.patch
mm-memory-failurec-fix-page-isolated-count-mismatch.patch
compaction-checks-correct-fragmentation-index.patch
mm-compaction-ensure-that-the-compaction-free-scanner-does-not-move-to-the-next-zone.patch
mm-vmscan-do-not-use-page_count-without-a-page-pin.patch
mm-compaction-abort-compaction-if-too-many-pages-are-isolated-and-caller-is-asynchronous-v2.patch
documentation-feature-removal-scheduletxt-remove-ns_cgroup-from-feature-removal-scheduletxt.patch
drivers-char-hpetc-fix-periodic-emulation-for-delayed-interrupts.patch
drivers-tty-serial-pch_uartc-dont-oops-if-dmi_get_system_info-returns-null.patch
rtc-fix-build-warnings-in-defconfigs.patch
ksm-fix-null-pointer-dereference-in-scan_get_next_rmap_item.patch
drivers-misc-apds990xc-apds990x_chip_on-should-depend-on-config_pm-config_pm_runtime.patch
alpha-fix-several-security-issues.patch
mm-move-vmtruncate_range-to-truncatec.patch
mm-move-shmem-prototypes-to-shmem_fsh.patch
tmpfs-take-control-of-its-truncate_range.patch
tmpfs-add-shmem_read_mapping_page_gfp.patch
drm-ttm-use-shmem_read_mapping_page.patch
drm-i915-use-shmem_read_mapping_page.patch
drm-i915-use-shmem_truncate_range.patch
drm-i915-more-struct_mutex-locking.patch
drm-i915-more-struct_mutex-locking-fix.patch
mm-cleanup-descriptions-of-filler-arg.patch
mm-truncate-functions-are-in-truncatec.patch
mm-tidy-vmtruncate_range-and-related-functions.patch
mm-consistent-truncate-and-invalidate-loops.patch
mm-pincer-in-truncate_inode_pages_range.patch
tmpfs-no-need-to-use-i_lock.patch
mm-nommuc-fix-remap_pfn_range.patch
linux-next.patch
next-remove-localversion.patch
i-need-old-gcc.patch
arch-alpha-kernel-systblss-remove-debug-check.patch
bdi_min_ratio-never-shrinks-ultimately-preventing-valid-setting-of-min_ratio.patch
cris-fix-a-build-error-in-kernel-forkc.patch
cris-fix-a-build-error-in-kernel-forkc-checkpatch-fixes.patch
cris-fix-a-build-error-in-sync_serial_open.patch
cris-fix-the-prototype-of-sync_serial_ioctl.patch
cris-add-missing-declaration-of-kgdb_init-and-breakpoint.patch
hfsplus-add-missing-call-to-bio_put.patch
drivers-scsi-pmcraid-reject-negative-request-size.patch
drivers-scsi-iprc-reorder-error-handling-code-to-include-iounmap.patch
timerfd-really-wake-up-processes-when-timer-is-cancelled-on-clock-change.patch
thermal-hide-config_thermal_hwmon.patch
thermal-split-hwmon-lookup-to-a-separate-function.patch
thermal-make-thermal_hwmon-implementation-fully-internal.patch
acerhdf-add-support-for-aspire-1410-bios-v13314.patch
arch-x86-include-asm-delayh-fix-udelay-and-ndelay-for-8-bit-args.patch
x86-fix-mmap-random-address-range.patch
leds-new-pcengines-alix-system-driver-enables-leds-via-gpio-interface.patch
arch-arm-mach-ux500-mbox-db5500c-world-writable-sysfs-fifo-file.patch
audit-always-follow-va_copy-with-va_end.patch
btrfs-dont-dereference-extent_mapping-if-null.patch
fb-fix-potential-deadlock-between-lock_fb_info-and-console_lock.patch
cyber2000fb-avoid-palette-corruption-at-higher-clocks.patch
i915-add-native-backlight-control.patch
btusb-patch-add_apple_macbookpro62.patch
pci-dmar-update-dmar-units-devices-list-during-hotplug.patch
drivers-firmware-dmi_scanc-make-dmi_name_in_vendors-more-focused.patch
pci-enumerate-the-pci-device-only-removed-out-pci-hierarchy-of-os-when-re-scanning-pci.patch
pci-enumerate-the-pci-device-only-removed-out-pci-hierarchy-of-os-when-re-scanning-pci-fix.patch
scsi-fix-a-header-to-include-linux-typesh.patch
drivers-scsi-megaraidc-fix-sparse-warnings.patch
drivers-block-brdc-make-brd_make_request-return-error-code.patch
staging-iio-make-iio-depend-on-generic_hardirqs.patch
drivers-staging-speakup-devsynthc-fix-buffer-size-is-not-provably-correct-error.patch
drivers-staging-gma500-psb_intel_displayc-fix-build.patch
drivers-staging-dt3155v4l-dt3155v4lc-needs-slabh.patch
drivers-staging-solo6x10-corec-needs-slabh.patch
drivers-staging-solo6x10-p2mc-needs-slabh.patch
staging-more-missing-slabh-inclusions.patch
slab-use-numa_no_node.patch
mm.patch
mm-extend-memory-hotplug-api-to-allow-memory-hotplug-in-virtual-machines.patch
mm-extend-memory-hotplug-api-to-allow-memory-hotplug-in-virtual-machines-fix.patch
xen-balloon-memory-hotplug-support-for-xen-balloon-driver.patch
mm-swap-token-fix-dead-link.patch
mm-swap-token-makes-global-variables-to-function-local.patch
mm-swap-token-add-a-comment-for-priority-aging.patch
pagewalk-fix-walk_page_range-dont-check-find_vma-result-properly.patch
pagewalk-dont-look-up-vma-if-walk-hugetlb_entry-is-unused.patch
pagewalk-add-locking-rule-comments.patch
pagewalk-add-locking-rule-comments-fix.patch
pagewalk-fix-code-comment-for-thp.patch
mm-dmapool-fix-possible-use-after-free-in-dmam_pool_destroy.patch
mm-remove-the-leftovers-of-noswapaccount.patch
frv-hook-up-gpiolib-support.patch
frv-duplicate-output_buffer-of-e03.patch
frv-duplicate-output_buffer-of-e03-checkpatch-fixes.patch
hpet-factor-timer-allocate-from-open.patch
intel_idle-fix-api-misuse.patch
intel_idle-disable-auto_demotion-for-hotplugged-cpus.patch
cris-fix-some-build-warnings-in-pinmuxc.patch
drivers-use-kzalloc-kcalloc-instead-of-kmallocmemset-where-possible.patch
asm-generic-systemh-drop-useless-__kernel__.patch
lpfc-silence-debug_strict_user_copy_checks=y-warning.patch
kprobes-silence-debug_strict_user_copy_checks=y-warning.patch
x86-implement-strict-user-copy-checks-for-x86_64.patch
consolidate-config_debug_strict_user_copy_checks.patch
fcntlf_setfl-allow-setting-of-o_sync.patch
leds-route-kbd-leds-through-the-generic-leds-layer.patch
checkpatch-suggest-using-min_t-or-max_t-v2.patch
checkpatch-add-__rcu-as-a-sparse-modifier.patch
misc-eeprom-add-driver-for-microwire-93xx46-eeproms.patch
misc-eeprom-add-eeprom-access-driver-for-digsy_mtc-board.patch
lib-hexdumpc-make-hex2bin-return-the-updated-src-address.patch
fs-binfmt_miscc-use-kernels-hex_to_bin-method.patch
fs-binfmt_miscc-use-kernels-hex_to_bin-method-fix.patch
fs-binfmt_miscc-use-kernels-hex_to_bin-method-fix-fix.patch
init-skip-calibration-delay-if-previously-done.patch
init-skip-calibration-delay-if-previously-done-fix.patch
init-skip-calibration-delay-if-previously-done-fix-fix.patch
init-skip-calibration-delay-if-previously-done-fix-fix-fix.patch
init-calibratec-calibrate_delay-tidy-up-the-pr_info-messages.patch
drivers-rtc-rtc-mpc5121c-add-support-for-rtc-on-mpc5200.patch
drivers-rtc-add-support-for-qualcomm-pmic8xxx-rtc.patch
drivers-rtc-add-support-for-qualcomm-pmic8xxx-rtc-fix.patch
drivers-rtc-rtc-ds1307c-add-support-for-the-pt7c4338-rtc-device.patch
memcg-do-not-expose-uninitialized-mem_cgroup_per_node-to-world.patch
cpusets-randomize-node-rotor-used-in-cpuset_mem_spread_node.patch
cpusets-randomize-node-rotor-used-in-cpuset_mem_spread_node-fix-2.patch
cpusets-randomize-node-rotor-used-in-cpuset_mem_spread_node-cpusets-initialize-spread-rotor-lazily.patch
cpusets-randomize-node-rotor-used-in-cpuset_mem_spread_node-cpusets-initialize-spread-rotor-lazily-fix.patch
ptrace-unify-show_regs-prototype.patch
ptrace-unify-show_regs-prototype-fix.patch
kernel-forkc-fix-a-few-coding-style-issues.patch
cpumask-convert-for_each_cpumask-with-for_each_cpu.patch
cpumask-alloc_cpumask_var-use-numa_no_node.patch
cpumask-add-cpumask_var_t-documentation.patch
sysctl-add-proc_dointvec_bool-handler.patch
sysctl-use-proc_dointvec_bool-where-appropriate.patch
sysctl-add-proc_dointvec_unsigned-handler.patch
sysctl-add-proc_dointvec_unsigned-handler-update.patch
sysctl-use-proc_dointvec_unsigned-where-appropriate.patch
scatterlist-new-helper-functions.patch
scatterlist-new-helper-functions-update.patch
scatterlist-new-helper-functions-update-fix.patch
memstick-add-support-for-legacy-memorysticks.patch
memstick-add-support-for-legacy-memorysticks-update-2.patch
kexec-remove-kmsg_dump_kexec.patch
make-sure-nobodys-leaking-resources.patch
journal_add_journal_head-debug.patch
releasing-resources-with-children.patch
make-frame_pointer-default=y.patch
mutex-subsystem-synchro-test-module.patch
mutex-subsystem-synchro-test-module-fix.patch
slab-leaks3-default-y.patch
put_bh-debug.patch
add-debugging-aid-for-memory-initialisation-problems.patch
workaround-for-a-pci-restoring-bug.patch
prio_tree-debugging-patch.patch
single_open-seq_release-leak-diagnostics.patch
add-a-refcount-check-in-dput.patch
memblock-add-input-size-checking-to-memblock_find_region.patch
memblock-add-input-size-checking-to-memblock_find_region-fix.patch


2011-06-16 01:30:20

by Randy Dunlap

[permalink] [raw]
Subject: Re: mmotm 2011-06-15-16-56 uploaded (UML build error)

On Wed, 15 Jun 2011 16:56:49 -0700 [email protected] wrote:

> The mm-of-the-moment snapshot 2011-06-15-16-56 has been uploaded to
>
> http://userweb.kernel.org/~akpm/mmotm/
>
> and will soon be available at
> git://zen-kernel.org/kernel/mmotm.git
> or
> git://git.cmpxchg.org/linux-mmotm.git
>
> It contains the following patches against 3.0-rc3:


When building UML for x86_64 (defconfig), I get:

fs/built-in.o: In function `__bprm_mm_init':
mmotm-2011-0615-1656/fs/exec.c:280: undefined reference to `__build_bug_on_failed'

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

2011-06-16 04:45:00

by Randy Dunlap

[permalink] [raw]
Subject: Re: mmotm 2011-06-15-16-56 uploaded (mm/migrate)

On Wed, 15 Jun 2011 16:56:49 -0700 [email protected] wrote:

> The mm-of-the-moment snapshot 2011-06-15-16-56 has been uploaded to
>
> http://userweb.kernel.org/~akpm/mmotm/
>
> and will soon be available at
> git://zen-kernel.org/kernel/mmotm.git
> or
> git://git.cmpxchg.org/linux-mmotm.git
>
> It contains the following patches against 3.0-rc3:


(i386 build:)

mm/built-in.o: In function `migrate_page_move_mapping':
migrate.c:(.text+0x22208): undefined reference to `swapper_space'

full kernel .config file is attached.


---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***


Attachments:
config-r8128 (38.52 kB)

2011-06-16 04:49:40

by Randy Dunlap

[permalink] [raw]
Subject: Re: mmotm 2011-06-15-16-56 uploaded (mm/page_cgroup.c)

On Wed, 15 Jun 2011 16:56:49 -0700 [email protected] wrote:

> The mm-of-the-moment snapshot 2011-06-15-16-56 has been uploaded to
>
> http://userweb.kernel.org/~akpm/mmotm/
>
> and will soon be available at
> git://zen-kernel.org/kernel/mmotm.git
> or
> git://git.cmpxchg.org/linux-mmotm.git
>
> It contains the following patches against 3.0-rc3:


(x86_64 build:)

mm/page_cgroup.c: In function 'page_cgroup_init':
mm/page_cgroup.c:308: error: implicit declaration of function 'node_start_pfn'
mm/page_cgroup.c:309: error: implicit declaration of function 'node_end_pfn'


full kernel .config file is attached.


---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***


Attachments:
config-r8136 (40.88 kB)

2011-06-16 05:55:49

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: Re: mmotm 2011-06-15-16-56 uploaded (mm/page_cgroup.c)

On Wed, 15 Jun 2011 21:49:17 -0700
Randy Dunlap <[email protected]> wrote:

> On Wed, 15 Jun 2011 16:56:49 -0700 [email protected] wrote:
>
> > The mm-of-the-moment snapshot 2011-06-15-16-56 has been uploaded to
> >
> > http://userweb.kernel.org/~akpm/mmotm/
> >
> > and will soon be available at
> > git://zen-kernel.org/kernel/mmotm.git
> > or
> > git://git.cmpxchg.org/linux-mmotm.git
> >
> > It contains the following patches against 3.0-rc3:
>
>
> (x86_64 build:)
>
> mm/page_cgroup.c: In function 'page_cgroup_init':
> mm/page_cgroup.c:308: error: implicit declaration of function 'node_start_pfn'
> mm/page_cgroup.c:309: error: implicit declaration of function 'node_end_pfn'
>
>
> full kernel .config file is attached.
>
Thank you. I'll dig today.

-Kame

2011-06-16 08:35:21

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: Re: mmotm 2011-06-15-16-56 uploaded (mm/page_cgroup.c)

On Wed, 15 Jun 2011 21:49:17 -0700
Randy Dunlap <[email protected]> wrote:

> On Wed, 15 Jun 2011 16:56:49 -0700 [email protected] wrote:
>
> > The mm-of-the-moment snapshot 2011-06-15-16-56 has been uploaded to
> >
> > http://userweb.kernel.org/~akpm/mmotm/
> >
> > and will soon be available at
> > git://zen-kernel.org/kernel/mmotm.git
> > or
> > git://git.cmpxchg.org/linux-mmotm.git
> >
> > It contains the following patches against 3.0-rc3:
>
>
> (x86_64 build:)
>
> mm/page_cgroup.c: In function 'page_cgroup_init':
> mm/page_cgroup.c:308: error: implicit declaration of function 'node_start_pfn'
> mm/page_cgroup.c:309: error: implicit declaration of function 'node_end_pfn'
>
>

Bug fix is here. Added CC to Mel to get review.
==
>From add3b670119f1c1f762194b432d3997d595bc213 Mon Sep 17 00:00:00 2001
From: KAMEZAWA Hiroyuki <[email protected]>
Date: Thu, 16 Jun 2011 17:28:07 +0900
Subject: [PATCH] Fix node_start/end_pfn() definition for mm/page_cgroup.c

commit 21a3c96 uses node_start/end_pfn(nid) for detection start/end
of nodes. But, it's not defined in linux/mmzone.h but defined in
/arch/???/include/mmzone.h which is included only under
CONFIG_NEED_MULTIPLE_NODES=y.

Then, we see
mm/page_cgroup.c: In function 'page_cgroup_init':
mm/page_cgroup.c:308: error: implicit declaration of function 'node_start_pfn'
mm/page_cgroup.c:309: error: implicit declaration of function 'node_end_pfn'

So, fixing page_cgroup.c is an idea...

But node_start_pfn()/node_end_pfn() is a very generic macro and
should be implemented in the same manner for all archs.
(m32r has different implementation...)

This patch removes definitions of node_start/end_pfn() in each archs
and defines a unified one in linux/mmzone.h. It's not under
CONFIG_NEED_MULTIPLE_NODES, now.

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>
---
arch/alpha/include/asm/mmzone.h | 1 -
arch/m32r/include/asm/mmzone.h | 8 +-------
arch/parisc/include/asm/mmzone.h | 7 -------
arch/powerpc/include/asm/mmzone.h | 7 -------
arch/sh/include/asm/mmzone.h | 4 ----
arch/sparc/include/asm/mmzone.h | 2 --
arch/tile/include/asm/mmzone.h | 11 -----------
arch/x86/include/asm/mmzone_32.h | 11 -----------
arch/x86/include/asm/mmzone_64.h | 3 ---
include/linux/mmzone.h | 3 +++
10 files changed, 4 insertions(+), 53 deletions(-)

diff --git a/arch/alpha/include/asm/mmzone.h b/arch/alpha/include/asm/mmzone.h
index 8af56ce..445dc42 100644
--- a/arch/alpha/include/asm/mmzone.h
+++ b/arch/alpha/include/asm/mmzone.h
@@ -56,7 +56,6 @@ PLAT_NODE_DATA_LOCALNR(unsigned long p, int n)
* Given a kernel address, find the home node of the underlying memory.
*/
#define kvaddr_to_nid(kaddr) pa_to_nid(__pa(kaddr))
-#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)

/*
* Given a kaddr, LOCAL_BASE_ADDR finds the owning node of the memory
diff --git a/arch/m32r/include/asm/mmzone.h b/arch/m32r/include/asm/mmzone.h
index 9f3b5ac..115ced3 100644
--- a/arch/m32r/include/asm/mmzone.h
+++ b/arch/m32r/include/asm/mmzone.h
@@ -14,12 +14,6 @@ extern struct pglist_data *node_data[];
#define NODE_DATA(nid) (node_data[nid])

#define node_localnr(pfn, nid) ((pfn) - NODE_DATA(nid)->node_start_pfn)
-#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
-#define node_end_pfn(nid) \
-({ \
- pg_data_t *__pgdat = NODE_DATA(nid); \
- __pgdat->node_start_pfn + __pgdat->node_spanned_pages - 1; \
-})

#define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))
/*
@@ -44,7 +38,7 @@ static __inline__ int pfn_to_nid(unsigned long pfn)
int node;

for (node = 0 ; node < MAX_NUMNODES ; node++)
- if (pfn >= node_start_pfn(node) && pfn <= node_end_pfn(node))
+ if (pfn >= node_start_pfn(node) && pfn < node_end_pfn(node))
break;

return node;
diff --git a/arch/parisc/include/asm/mmzone.h b/arch/parisc/include/asm/mmzone.h
index 9608d2c..e67eb9c 100644
--- a/arch/parisc/include/asm/mmzone.h
+++ b/arch/parisc/include/asm/mmzone.h
@@ -14,13 +14,6 @@ extern struct node_map_data node_data[];

#define NODE_DATA(nid) (&node_data[nid].pg_data)

-#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
-#define node_end_pfn(nid) \
-({ \
- pg_data_t *__pgdat = NODE_DATA(nid); \
- __pgdat->node_start_pfn + __pgdat->node_spanned_pages; \
-})
-
/* We have these possible memory map layouts:
* Astro: 0-3.75, 67.75-68, 4-64
* zx1: 0-1, 257-260, 4-256
diff --git a/arch/powerpc/include/asm/mmzone.h b/arch/powerpc/include/asm/mmzone.h
index fd3fd58..7b58917 100644
--- a/arch/powerpc/include/asm/mmzone.h
+++ b/arch/powerpc/include/asm/mmzone.h
@@ -38,13 +38,6 @@ u64 memory_hotplug_max(void);
#define memory_hotplug_max() memblock_end_of_DRAM()
#endif

-/*
- * Following are macros that each numa implmentation must define.
- */
-
-#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
-#define node_end_pfn(nid) (NODE_DATA(nid)->node_end_pfn)
-
#else
#define memory_hotplug_max() memblock_end_of_DRAM()
#endif /* CONFIG_NEED_MULTIPLE_NODES */
diff --git a/arch/sh/include/asm/mmzone.h b/arch/sh/include/asm/mmzone.h
index 8887baf..15a8496 100644
--- a/arch/sh/include/asm/mmzone.h
+++ b/arch/sh/include/asm/mmzone.h
@@ -9,10 +9,6 @@
extern struct pglist_data *node_data[];
#define NODE_DATA(nid) (node_data[nid])

-#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
-#define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \
- NODE_DATA(nid)->node_spanned_pages)
-
static inline int pfn_to_nid(unsigned long pfn)
{
int nid;
diff --git a/arch/sparc/include/asm/mmzone.h b/arch/sparc/include/asm/mmzone.h
index e8c6487..99d9b9f 100644
--- a/arch/sparc/include/asm/mmzone.h
+++ b/arch/sparc/include/asm/mmzone.h
@@ -8,8 +8,6 @@
extern struct pglist_data *node_data[];

#define NODE_DATA(nid) (node_data[nid])
-#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
-#define node_end_pfn(nid) (NODE_DATA(nid)->node_end_pfn)

extern int numa_cpu_lookup_table[];
extern cpumask_t numa_cpumask_lookup_table[];
diff --git a/arch/tile/include/asm/mmzone.h b/arch/tile/include/asm/mmzone.h
index c6344c4..9d3dbce 100644
--- a/arch/tile/include/asm/mmzone.h
+++ b/arch/tile/include/asm/mmzone.h
@@ -40,17 +40,6 @@ static inline int pfn_to_nid(unsigned long pfn)
return highbits_to_node[__pfn_to_highbits(pfn)];
}

-/*
- * Following are macros that each numa implmentation must define.
- */
-
-#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
-#define node_end_pfn(nid) \
-({ \
- pg_data_t *__pgdat = NODE_DATA(nid); \
- __pgdat->node_start_pfn + __pgdat->node_spanned_pages; \
-})
-
#define kern_addr_valid(kaddr) virt_addr_valid((void *)kaddr)

static inline int pfn_valid(int pfn)
diff --git a/arch/x86/include/asm/mmzone_32.h b/arch/x86/include/asm/mmzone_32.h
index 5e83a41..224e8c5 100644
--- a/arch/x86/include/asm/mmzone_32.h
+++ b/arch/x86/include/asm/mmzone_32.h
@@ -48,17 +48,6 @@ static inline int pfn_to_nid(unsigned long pfn)
#endif
}

-/*
- * Following are macros that each numa implmentation must define.
- */
-
-#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
-#define node_end_pfn(nid) \
-({ \
- pg_data_t *__pgdat = NODE_DATA(nid); \
- __pgdat->node_start_pfn + __pgdat->node_spanned_pages; \
-})
-
static inline int pfn_valid(int pfn)
{
int nid = pfn_to_nid(pfn);
diff --git a/arch/x86/include/asm/mmzone_64.h b/arch/x86/include/asm/mmzone_64.h
index b3f88d7..129d9aa 100644
--- a/arch/x86/include/asm/mmzone_64.h
+++ b/arch/x86/include/asm/mmzone_64.h
@@ -13,8 +13,5 @@ extern struct pglist_data *node_data[];

#define NODE_DATA(nid) (node_data[nid])

-#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
-#define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \
- NODE_DATA(nid)->node_spanned_pages)
#endif
#endif /* _ASM_X86_MMZONE_64_H */
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index c928dac..892862e 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -647,6 +647,9 @@ typedef struct pglist_data {
#endif
#define nid_page_nr(nid, pagenr) pgdat_page_nr(NODE_DATA(nid),(pagenr))

+#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
+#define node_end_pfn(nid) (node_start_pfn(nid) + node_spanned_pages(nid))
+
#include <linux/memory_hotplug.h>

extern struct mutex zonelists_mutex;
--
1.7.4.1

2011-06-16 10:36:12

by Mel Gorman

[permalink] [raw]
Subject: Re: mmotm 2011-06-15-16-56 uploaded (mm/page_cgroup.c)

On Thu, Jun 16, 2011 at 05:28:19PM +0900, KAMEZAWA Hiroyuki wrote:
> On Wed, 15 Jun 2011 21:49:17 -0700
> Randy Dunlap <[email protected]> wrote:
>
> > On Wed, 15 Jun 2011 16:56:49 -0700 [email protected] wrote:
> >
> > > The mm-of-the-moment snapshot 2011-06-15-16-56 has been uploaded to
> > >
> > > http://userweb.kernel.org/~akpm/mmotm/
> > >
> > > and will soon be available at
> > > git://zen-kernel.org/kernel/mmotm.git
> > > or
> > > git://git.cmpxchg.org/linux-mmotm.git
> > >
> > > It contains the following patches against 3.0-rc3:
> >
> >
> > (x86_64 build:)
> >
> > mm/page_cgroup.c: In function 'page_cgroup_init':
> > mm/page_cgroup.c:308: error: implicit declaration of function 'node_start_pfn'
> > mm/page_cgroup.c:309: error: implicit declaration of function 'node_end_pfn'
> >
> >
>
> Bug fix is here. Added CC to Mel to get review.
> ==
> From add3b670119f1c1f762194b432d3997d595bc213 Mon Sep 17 00:00:00 2001
> From: KAMEZAWA Hiroyuki <[email protected]>
> Date: Thu, 16 Jun 2011 17:28:07 +0900
> Subject: [PATCH] Fix node_start/end_pfn() definition for mm/page_cgroup.c
>
> commit 21a3c96 uses node_start/end_pfn(nid) for detection start/end
> of nodes. But, it's not defined in linux/mmzone.h but defined in
> /arch/???/include/mmzone.h which is included only under
> CONFIG_NEED_MULTIPLE_NODES=y.
>
> Then, we see
> mm/page_cgroup.c: In function 'page_cgroup_init':
> mm/page_cgroup.c:308: error: implicit declaration of function 'node_start_pfn'
> mm/page_cgroup.c:309: error: implicit declaration of function 'node_end_pfn'
>
> So, fixing page_cgroup.c is an idea...
>
> But node_start_pfn()/node_end_pfn() is a very generic macro and
> should be implemented in the same manner for all archs.
> (m32r has different implementation...)
>

I would expect node_start_pfn to always be the equivalent of
NODE_DATA(nid)->node_start_pfn and that does appear to be case even
though it is not universally defined;

alpha/include/asm/mmzone.h:#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
m32r/include/asm/mmzone.h:#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
parisc/include/asm/mmzone.h:#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
powerpc/include/asm/mmzone.h:#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
sh/include/asm/mmzone.h:#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
sparc/include/asm/mmzone.h:#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
tile/include/asm/mmzone.h:#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
x86/include/asm/mmzone_32.h:#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
x86/include/asm/mmzone_64.h:#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)

Similarly I would always expect node_end_pfn to be related to
node_spanned_pages which is true of x86, tile, sh and parisc. sparc
and powerpc uses node_end_pfn which is a good trick because that
is not a member of pglist_data (suspect they do not build on
!CONFIG_NEED_MULTIPLE_NODES?).

m32r does differ from everyone else in that it's
__pgdat->node_start_pfn + __pgdat->node_spanned_pages - 1 and this was
the case when it was introduced in 2004. It's not explained why it is
like this but I suspect it's a mistake and I think your cleanup is
appropriate.

> This patch removes definitions of node_start/end_pfn() in each archs
> and defines a unified one in linux/mmzone.h. It's not under
> CONFIG_NEED_MULTIPLE_NODES, now.
>

Does anyone remember *why* this did not happen in the first place? I
can't think of a good reason so I've cc'd Dave Hansen as he might
remember.

Would it also be worth cleaning up users of node_spanned_pages to
use node_end_pfn in mm/ where appropriate rather than having a mix
of spanned_pages and node_end_pfn?

> Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>

For the most part, it looks good! I haven't compile-tested this but
I did spot one one problem unfortunately;

> <SNIP>
> diff --git a/arch/x86/include/asm/mmzone_32.h b/arch/x86/include/asm/mmzone_32.h
> index 5e83a41..224e8c5 100644
> --- a/arch/x86/include/asm/mmzone_32.h
> +++ b/arch/x86/include/asm/mmzone_32.h
> @@ -48,17 +48,6 @@ static inline int pfn_to_nid(unsigned long pfn)
> #endif
> }
>
> -/*
> - * Following are macros that each numa implmentation must define.
> - */
> -
> -#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
> -#define node_end_pfn(nid) \
> -({ \
> - pg_data_t *__pgdat = NODE_DATA(nid); \
> - __pgdat->node_start_pfn + __pgdat->node_spanned_pages; \
> -})
> -
> static inline int pfn_valid(int pfn)
> {
> int nid = pfn_to_nid(pfn);
> diff --git a/arch/x86/include/asm/mmzone_64.h b/arch/x86/include/asm/mmzone_64.h
> index b3f88d7..129d9aa 100644
> --- a/arch/x86/include/asm/mmzone_64.h
> +++ b/arch/x86/include/asm/mmzone_64.h
> @@ -13,8 +13,5 @@ extern struct pglist_data *node_data[];
>
> #define NODE_DATA(nid) (node_data[nid])
>
> -#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
> -#define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \
> - NODE_DATA(nid)->node_spanned_pages)
> #endif
> #endif /* _ASM_X86_MMZONE_64_H */
> diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
> index c928dac..892862e 100644
> --- a/include/linux/mmzone.h
> +++ b/include/linux/mmzone.h
> @@ -647,6 +647,9 @@ typedef struct pglist_data {
> #endif
> #define nid_page_nr(nid, pagenr) pgdat_page_nr(NODE_DATA(nid),(pagenr))
>
> +#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
> +#define node_end_pfn(nid) (node_start_pfn(nid) + node_spanned_pages(nid))
> +

A caller that does node_end_pfn(nid++) will get a nasty surprise
due to side-effects. I know architectures currently get this wrong
including x86_64 but we might as well fix it up now. The definition
in arch/x86/include/asm/mmzone_32.h is immune to side-effects and
might be a better choice despite the use of a temporary variable.

> #include <linux/memory_hotplug.h>
>
> extern struct mutex zonelists_mutex;
> --
> 1.7.4.1
>
>

--
Mel Gorman
SUSE Labs

2011-06-16 16:26:30

by Dave Hansen

[permalink] [raw]
Subject: Re: mmotm 2011-06-15-16-56 uploaded (mm/page_cgroup.c)

On Thu, 2011-06-16 at 11:35 +0100, Mel Gorman wrote:
> > This patch removes definitions of node_start/end_pfn() in each archs
> > and defines a unified one in linux/mmzone.h. It's not under
> > CONFIG_NEED_MULTIPLE_NODES, now.
>
> Does anyone remember *why* this did not happen in the first place? I
> can't think of a good reason so I've cc'd Dave Hansen as he might
> remember.

You mean why it's not under CONFIG_NEED_MULTIPLE_NODES? I'd guess it's
just because it keeps working in all configurations since the
pg_data_t->node_*_pfn entries are defined everywhere.

Is that what you're asking?

-- Dave

2011-06-16 16:51:55

by Mel Gorman

[permalink] [raw]
Subject: Re: mmotm 2011-06-15-16-56 uploaded (mm/page_cgroup.c)

On Thu, Jun 16, 2011 at 09:25:42AM -0700, Dave Hansen wrote:
> On Thu, 2011-06-16 at 11:35 +0100, Mel Gorman wrote:
> > > This patch removes definitions of node_start/end_pfn() in each archs
> > > and defines a unified one in linux/mmzone.h. It's not under
> > > CONFIG_NEED_MULTIPLE_NODES, now.
> >
> > Does anyone remember *why* this did not happen in the first place? I
> > can't think of a good reason so I've cc'd Dave Hansen as he might
> > remember.
>
> You mean why it's not under CONFIG_NEED_MULTIPLE_NODES? I'd guess it's
> just because it keeps working in all configurations since the
> pg_data_t->node_*_pfn entries are defined everywhere.
>
> Is that what you're asking?
>

No, why was node_start_pfn() and node_end_pfn() defined optionally
on a per-architecture basis?

--
Mel Gorman
SUSE Labs

2011-06-16 18:46:35

by Dave Hansen

[permalink] [raw]
Subject: Re: mmotm 2011-06-15-16-56 uploaded (mm/page_cgroup.c)

On Thu, 2011-06-16 at 17:51 +0100, Mel Gorman wrote:
> No, why was node_start_pfn() and node_end_pfn() defined optionally
> on a per-architecture basis?

Probably because it started in the NUMA-Q port, and we were still trying
to stay off the radar at that point. It looks like it showed up in
~2.5.[3-4]?. We didn't know what the heck we were doing back then, and
it probably leaked out from under CONFIG_NUMA/DISCONTIGMEM at some
point.

Seems like a good thing to consolidate to me. Especially since it's
just a shortcut to the (unconditionally defined) structure member, I
can't see a real justification for needing different definitions.

-- Dave

2011-06-17 00:53:51

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: [BUGFIX][PATCH][-rc3] Define a consolidated definition of node_start/end_pfn for build error in page_cgroup.c (Was Re: mmotm 2011-06-15-16-56 uploaded (mm/page_cgroup.c)

On Thu, 16 Jun 2011 11:35:59 +0100
Mel Gorman <[email protected]> wrote:

> A caller that does node_end_pfn(nid++) will get a nasty surprise
> due to side-effects. I know architectures currently get this wrong
> including x86_64 but we might as well fix it up now. The definition
> in arch/x86/include/asm/mmzone_32.h is immune to side-effects and
> might be a better choice despite the use of a temporary variable.
>

Ok, here is a fixed one. Thank you for comments/review.
==
>From 507cc95c5ba2351bff16c5421255d1395a3b555b Mon Sep 17 00:00:00 2001
From: KAMEZAWA Hiroyuki <[email protected]>
Date: Thu, 16 Jun 2011 17:28:07 +0900
Subject: [PATCH] Fix node_start/end_pfn() definition for mm/page_cgroup.c

commit 21a3c96 uses node_start/end_pfn(nid) for detection start/end
of nodes. But, it's not defined in linux/mmzone.h but defined in
/arch/???/include/mmzone.h which is included only under
CONFIG_NEED_MULTIPLE_NODES=y.

Then, we see
mm/page_cgroup.c: In function 'page_cgroup_init':
mm/page_cgroup.c:308: error: implicit declaration of function 'node_start_pfn'
mm/page_cgroup.c:309: error: implicit declaration of function 'node_end_pfn'

So, fixiing page_cgroup.c is an idea...

But node_start_pfn()/node_end_pfn() is a very generic macro and
should be implemented in the same manner for all archs.
(m32r has different implementation...)

This patch removes definitions of node_start/end_pfn() in each archs
and defines a unified one in linux/mmzone.h. It's not under
CONFIG_NEED_MULTIPLE_NODES, now.

A result of macro expansion is here (mm/page_cgroup.c)

for !NUMA
start_pfn = ((&contig_page_data)->node_start_pfn);
end_pfn = ({ pg_data_t *__pgdat = (&contig_page_data); __pgdat->node_start_pfn + __pgdat->node_spanned_pages;});

for NUMA (x86-64)
start_pfn = ((node_data[nid])->node_start_pfn);
end_pfn = ({ pg_data_t *__pgdat = (node_data[nid]); __pgdat->node_start_pfn + __pgdat->node_spanned_pages;});


Reported-by: Randy Dunlap <[email protected]>
Reported-by: Ingo Molnar <[email protected]>
Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>

Changelog:
- fixed to avoid using "nid" twice in node_end_pfn() macro.
---
arch/alpha/include/asm/mmzone.h | 1 -
arch/m32r/include/asm/mmzone.h | 8 +-------
arch/parisc/include/asm/mmzone.h | 7 -------
arch/powerpc/include/asm/mmzone.h | 7 -------
arch/sh/include/asm/mmzone.h | 4 ----
arch/sparc/include/asm/mmzone.h | 2 --
arch/tile/include/asm/mmzone.h | 11 -----------
arch/x86/include/asm/mmzone_32.h | 11 -----------
arch/x86/include/asm/mmzone_64.h | 3 ---
include/linux/mmzone.h | 7 +++++++
10 files changed, 8 insertions(+), 53 deletions(-)

diff --git a/arch/alpha/include/asm/mmzone.h b/arch/alpha/include/asm/mmzone.h
index 8af56ce..445dc42 100644
--- a/arch/alpha/include/asm/mmzone.h
+++ b/arch/alpha/include/asm/mmzone.h
@@ -56,7 +56,6 @@ PLAT_NODE_DATA_LOCALNR(unsigned long p, int n)
* Given a kernel address, find the home node of the underlying memory.
*/
#define kvaddr_to_nid(kaddr) pa_to_nid(__pa(kaddr))
-#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)

/*
* Given a kaddr, LOCAL_BASE_ADDR finds the owning node of the memory
diff --git a/arch/m32r/include/asm/mmzone.h b/arch/m32r/include/asm/mmzone.h
index 9f3b5ac..115ced3 100644
--- a/arch/m32r/include/asm/mmzone.h
+++ b/arch/m32r/include/asm/mmzone.h
@@ -14,12 +14,6 @@ extern struct pglist_data *node_data[];
#define NODE_DATA(nid) (node_data[nid])

#define node_localnr(pfn, nid) ((pfn) - NODE_DATA(nid)->node_start_pfn)
-#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
-#define node_end_pfn(nid) \
-({ \
- pg_data_t *__pgdat = NODE_DATA(nid); \
- __pgdat->node_start_pfn + __pgdat->node_spanned_pages - 1; \
-})

#define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))
/*
@@ -44,7 +38,7 @@ static __inline__ int pfn_to_nid(unsigned long pfn)
int node;

for (node = 0 ; node < MAX_NUMNODES ; node++)
- if (pfn >= node_start_pfn(node) && pfn <= node_end_pfn(node))
+ if (pfn >= node_start_pfn(node) && pfn < node_end_pfn(node))
break;

return node;
diff --git a/arch/parisc/include/asm/mmzone.h b/arch/parisc/include/asm/mmzone.h
index 9608d2c..e67eb9c 100644
--- a/arch/parisc/include/asm/mmzone.h
+++ b/arch/parisc/include/asm/mmzone.h
@@ -14,13 +14,6 @@ extern struct node_map_data node_data[];

#define NODE_DATA(nid) (&node_data[nid].pg_data)

-#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
-#define node_end_pfn(nid) \
-({ \
- pg_data_t *__pgdat = NODE_DATA(nid); \
- __pgdat->node_start_pfn + __pgdat->node_spanned_pages; \
-})
-
/* We have these possible memory map layouts:
* Astro: 0-3.75, 67.75-68, 4-64
* zx1: 0-1, 257-260, 4-256
diff --git a/arch/powerpc/include/asm/mmzone.h b/arch/powerpc/include/asm/mmzone.h
index fd3fd58..7b58917 100644
--- a/arch/powerpc/include/asm/mmzone.h
+++ b/arch/powerpc/include/asm/mmzone.h
@@ -38,13 +38,6 @@ u64 memory_hotplug_max(void);
#define memory_hotplug_max() memblock_end_of_DRAM()
#endif

-/*
- * Following are macros that each numa implmentation must define.
- */
-
-#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
-#define node_end_pfn(nid) (NODE_DATA(nid)->node_end_pfn)
-
#else
#define memory_hotplug_max() memblock_end_of_DRAM()
#endif /* CONFIG_NEED_MULTIPLE_NODES */
diff --git a/arch/sh/include/asm/mmzone.h b/arch/sh/include/asm/mmzone.h
index 8887baf..15a8496 100644
--- a/arch/sh/include/asm/mmzone.h
+++ b/arch/sh/include/asm/mmzone.h
@@ -9,10 +9,6 @@
extern struct pglist_data *node_data[];
#define NODE_DATA(nid) (node_data[nid])

-#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
-#define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \
- NODE_DATA(nid)->node_spanned_pages)
-
static inline int pfn_to_nid(unsigned long pfn)
{
int nid;
diff --git a/arch/sparc/include/asm/mmzone.h b/arch/sparc/include/asm/mmzone.h
index e8c6487..99d9b9f 100644
--- a/arch/sparc/include/asm/mmzone.h
+++ b/arch/sparc/include/asm/mmzone.h
@@ -8,8 +8,6 @@
extern struct pglist_data *node_data[];

#define NODE_DATA(nid) (node_data[nid])
-#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
-#define node_end_pfn(nid) (NODE_DATA(nid)->node_end_pfn)

extern int numa_cpu_lookup_table[];
extern cpumask_t numa_cpumask_lookup_table[];
diff --git a/arch/tile/include/asm/mmzone.h b/arch/tile/include/asm/mmzone.h
index c6344c4..9d3dbce 100644
--- a/arch/tile/include/asm/mmzone.h
+++ b/arch/tile/include/asm/mmzone.h
@@ -40,17 +40,6 @@ static inline int pfn_to_nid(unsigned long pfn)
return highbits_to_node[__pfn_to_highbits(pfn)];
}

-/*
- * Following are macros that each numa implmentation must define.
- */
-
-#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
-#define node_end_pfn(nid) \
-({ \
- pg_data_t *__pgdat = NODE_DATA(nid); \
- __pgdat->node_start_pfn + __pgdat->node_spanned_pages; \
-})
-
#define kern_addr_valid(kaddr) virt_addr_valid((void *)kaddr)

static inline int pfn_valid(int pfn)
diff --git a/arch/x86/include/asm/mmzone_32.h b/arch/x86/include/asm/mmzone_32.h
index 5e83a41..224e8c5 100644
--- a/arch/x86/include/asm/mmzone_32.h
+++ b/arch/x86/include/asm/mmzone_32.h
@@ -48,17 +48,6 @@ static inline int pfn_to_nid(unsigned long pfn)
#endif
}

-/*
- * Following are macros that each numa implmentation must define.
- */
-
-#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
-#define node_end_pfn(nid) \
-({ \
- pg_data_t *__pgdat = NODE_DATA(nid); \
- __pgdat->node_start_pfn + __pgdat->node_spanned_pages; \
-})
-
static inline int pfn_valid(int pfn)
{
int nid = pfn_to_nid(pfn);
diff --git a/arch/x86/include/asm/mmzone_64.h b/arch/x86/include/asm/mmzone_64.h
index b3f88d7..129d9aa 100644
--- a/arch/x86/include/asm/mmzone_64.h
+++ b/arch/x86/include/asm/mmzone_64.h
@@ -13,8 +13,5 @@ extern struct pglist_data *node_data[];

#define NODE_DATA(nid) (node_data[nid])

-#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
-#define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \
- NODE_DATA(nid)->node_spanned_pages)
#endif
#endif /* _ASM_X86_MMZONE_64_H */
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index c928dac..9f7c3eb 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -647,6 +647,13 @@ typedef struct pglist_data {
#endif
#define nid_page_nr(nid, pagenr) pgdat_page_nr(NODE_DATA(nid),(pagenr))

+#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
+
+#define node_end_pfn(nid) ({\
+ pg_data_t *__pgdat = NODE_DATA(nid);\
+ __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\
+})
+
#include <linux/memory_hotplug.h>

extern struct mutex zonelists_mutex;
--
1.7.4.1

2011-06-17 07:56:11

by Mel Gorman

[permalink] [raw]
Subject: Re: mmotm 2011-06-15-16-56 uploaded (mm/page_cgroup.c)

On Thu, Jun 16, 2011 at 11:46:04AM -0700, Dave Hansen wrote:
> On Thu, 2011-06-16 at 17:51 +0100, Mel Gorman wrote:
> > No, why was node_start_pfn() and node_end_pfn() defined optionally
> > on a per-architecture basis?
>
> Probably because it started in the NUMA-Q port, and we were still trying
> to stay off the radar at that point. It looks like it showed up in
> ~2.5.[3-4]?. We didn't know what the heck we were doing back then, and
> it probably leaked out from under CONFIG_NUMA/DISCONTIGMEM at some
> point.
>
> Seems like a good thing to consolidate to me. Especially since it's
> just a shortcut to the (unconditionally defined) structure member, I
> can't see a real justification for needing different definitions.
>

Great. Thanks Dave.

--
Mel Gorman
SUSE Labs

2011-06-17 07:57:51

by Mel Gorman

[permalink] [raw]
Subject: Re: [BUGFIX][PATCH][-rc3] Define a consolidated definition of node_start/end_pfn for build error in page_cgroup.c (Was Re: mmotm 2011-06-15-16-56 uploaded (mm/page_cgroup.c)

On Fri, Jun 17, 2011 at 09:46:28AM +0900, KAMEZAWA Hiroyuki wrote:
> On Thu, 16 Jun 2011 11:35:59 +0100
> Mel Gorman <[email protected]> wrote:
>
> > A caller that does node_end_pfn(nid++) will get a nasty surprise
> > due to side-effects. I know architectures currently get this wrong
> > including x86_64 but we might as well fix it up now. The definition
> > in arch/x86/include/asm/mmzone_32.h is immune to side-effects and
> > might be a better choice despite the use of a temporary variable.
> >
>
> Ok, here is a fixed one. Thank you for comments/review.
> ==
> From 507cc95c5ba2351bff16c5421255d1395a3b555b Mon Sep 17 00:00:00 2001
> From: KAMEZAWA Hiroyuki <[email protected]>
> Date: Thu, 16 Jun 2011 17:28:07 +0900
> Subject: [PATCH] Fix node_start/end_pfn() definition for mm/page_cgroup.c
>
> commit 21a3c96 uses node_start/end_pfn(nid) for detection start/end
> of nodes. But, it's not defined in linux/mmzone.h but defined in
> /arch/???/include/mmzone.h which is included only under
> CONFIG_NEED_MULTIPLE_NODES=y.
>
> Then, we see
> mm/page_cgroup.c: In function 'page_cgroup_init':
> mm/page_cgroup.c:308: error: implicit declaration of function 'node_start_pfn'
> mm/page_cgroup.c:309: error: implicit declaration of function 'node_end_pfn'
>
> So, fixiing page_cgroup.c is an idea...
>
> But node_start_pfn()/node_end_pfn() is a very generic macro and
> should be implemented in the same manner for all archs.
> (m32r has different implementation...)
>
> This patch removes definitions of node_start/end_pfn() in each archs
> and defines a unified one in linux/mmzone.h. It's not under
> CONFIG_NEED_MULTIPLE_NODES, now.
>
> A result of macro expansion is here (mm/page_cgroup.c)
>
> for !NUMA
> start_pfn = ((&contig_page_data)->node_start_pfn);
> end_pfn = ({ pg_data_t *__pgdat = (&contig_page_data); __pgdat->node_start_pfn + __pgdat->node_spanned_pages;});
>
> for NUMA (x86-64)
> start_pfn = ((node_data[nid])->node_start_pfn);
> end_pfn = ({ pg_data_t *__pgdat = (node_data[nid]); __pgdat->node_start_pfn + __pgdat->node_spanned_pages;});
>
>
> Reported-by: Randy Dunlap <[email protected]>
> Reported-by: Ingo Molnar <[email protected]>
> Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>
>

Thanks.

Acked-by: Mel Gorman <[email protected]>

--
Mel Gorman
SUSE Labs

2011-06-17 16:59:20

by Randy Dunlap

[permalink] [raw]
Subject: Re: [BUGFIX][PATCH][-rc3] Define a consolidated definition of node_start/end_pfn for build error in page_cgroup.c (Was Re: mmotm 2011-06-15-16-56 uploaded (mm/page_cgroup.c)

On 06/16/11 17:46, KAMEZAWA Hiroyuki wrote:
> On Thu, 16 Jun 2011 11:35:59 +0100
> Mel Gorman <[email protected]> wrote:
>
>> A caller that does node_end_pfn(nid++) will get a nasty surprise
>> due to side-effects. I know architectures currently get this wrong
>> including x86_64 but we might as well fix it up now. The definition
>> in arch/x86/include/asm/mmzone_32.h is immune to side-effects and
>> might be a better choice despite the use of a temporary variable.
>>
>
> Ok, here is a fixed one. Thank you for comments/review.
> ==
> From 507cc95c5ba2351bff16c5421255d1395a3b555b Mon Sep 17 00:00:00 2001
> From: KAMEZAWA Hiroyuki <[email protected]>
> Date: Thu, 16 Jun 2011 17:28:07 +0900
> Subject: [PATCH] Fix node_start/end_pfn() definition for mm/page_cgroup.c
>
> commit 21a3c96 uses node_start/end_pfn(nid) for detection start/end
> of nodes. But, it's not defined in linux/mmzone.h but defined in
> /arch/???/include/mmzone.h which is included only under
> CONFIG_NEED_MULTIPLE_NODES=y.
>
> Then, we see
> mm/page_cgroup.c: In function 'page_cgroup_init':
> mm/page_cgroup.c:308: error: implicit declaration of function 'node_start_pfn'
> mm/page_cgroup.c:309: error: implicit declaration of function 'node_end_pfn'
>
> So, fixiing page_cgroup.c is an idea...
>
> But node_start_pfn()/node_end_pfn() is a very generic macro and
> should be implemented in the same manner for all archs.
> (m32r has different implementation...)
>
> This patch removes definitions of node_start/end_pfn() in each archs
> and defines a unified one in linux/mmzone.h. It's not under
> CONFIG_NEED_MULTIPLE_NODES, now.
>
> A result of macro expansion is here (mm/page_cgroup.c)
>
> for !NUMA
> start_pfn = ((&contig_page_data)->node_start_pfn);
> end_pfn = ({ pg_data_t *__pgdat = (&contig_page_data); __pgdat->node_start_pfn + __pgdat->node_spanned_pages;});
>
> for NUMA (x86-64)
> start_pfn = ((node_data[nid])->node_start_pfn);
> end_pfn = ({ pg_data_t *__pgdat = (node_data[nid]); __pgdat->node_start_pfn + __pgdat->node_spanned_pages;});
>
>
> Reported-by: Randy Dunlap <[email protected]>
> Reported-by: Ingo Molnar <[email protected]>
> Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>

Acked-by: Randy Dunlap <[email protected]>

Thanks.

>
> Changelog:
> - fixed to avoid using "nid" twice in node_end_pfn() macro.
> ---
> arch/alpha/include/asm/mmzone.h | 1 -
> arch/m32r/include/asm/mmzone.h | 8 +-------
> arch/parisc/include/asm/mmzone.h | 7 -------
> arch/powerpc/include/asm/mmzone.h | 7 -------
> arch/sh/include/asm/mmzone.h | 4 ----
> arch/sparc/include/asm/mmzone.h | 2 --
> arch/tile/include/asm/mmzone.h | 11 -----------
> arch/x86/include/asm/mmzone_32.h | 11 -----------
> arch/x86/include/asm/mmzone_64.h | 3 ---
> include/linux/mmzone.h | 7 +++++++
> 10 files changed, 8 insertions(+), 53 deletions(-)
>
> diff --git a/arch/alpha/include/asm/mmzone.h b/arch/alpha/include/asm/mmzone.h
> index 8af56ce..445dc42 100644
> --- a/arch/alpha/include/asm/mmzone.h
> +++ b/arch/alpha/include/asm/mmzone.h
> @@ -56,7 +56,6 @@ PLAT_NODE_DATA_LOCALNR(unsigned long p, int n)
> * Given a kernel address, find the home node of the underlying memory.
> */
> #define kvaddr_to_nid(kaddr) pa_to_nid(__pa(kaddr))
> -#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
>
> /*
> * Given a kaddr, LOCAL_BASE_ADDR finds the owning node of the memory
> diff --git a/arch/m32r/include/asm/mmzone.h b/arch/m32r/include/asm/mmzone.h
> index 9f3b5ac..115ced3 100644
> --- a/arch/m32r/include/asm/mmzone.h
> +++ b/arch/m32r/include/asm/mmzone.h
> @@ -14,12 +14,6 @@ extern struct pglist_data *node_data[];
> #define NODE_DATA(nid) (node_data[nid])
>
> #define node_localnr(pfn, nid) ((pfn) - NODE_DATA(nid)->node_start_pfn)
> -#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
> -#define node_end_pfn(nid) \
> -({ \
> - pg_data_t *__pgdat = NODE_DATA(nid); \
> - __pgdat->node_start_pfn + __pgdat->node_spanned_pages - 1; \
> -})
>
> #define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))
> /*
> @@ -44,7 +38,7 @@ static __inline__ int pfn_to_nid(unsigned long pfn)
> int node;
>
> for (node = 0 ; node < MAX_NUMNODES ; node++)
> - if (pfn >= node_start_pfn(node) && pfn <= node_end_pfn(node))
> + if (pfn >= node_start_pfn(node) && pfn < node_end_pfn(node))
> break;
>
> return node;
> diff --git a/arch/parisc/include/asm/mmzone.h b/arch/parisc/include/asm/mmzone.h
> index 9608d2c..e67eb9c 100644
> --- a/arch/parisc/include/asm/mmzone.h
> +++ b/arch/parisc/include/asm/mmzone.h
> @@ -14,13 +14,6 @@ extern struct node_map_data node_data[];
>
> #define NODE_DATA(nid) (&node_data[nid].pg_data)
>
> -#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
> -#define node_end_pfn(nid) \
> -({ \
> - pg_data_t *__pgdat = NODE_DATA(nid); \
> - __pgdat->node_start_pfn + __pgdat->node_spanned_pages; \
> -})
> -
> /* We have these possible memory map layouts:
> * Astro: 0-3.75, 67.75-68, 4-64
> * zx1: 0-1, 257-260, 4-256
> diff --git a/arch/powerpc/include/asm/mmzone.h b/arch/powerpc/include/asm/mmzone.h
> index fd3fd58..7b58917 100644
> --- a/arch/powerpc/include/asm/mmzone.h
> +++ b/arch/powerpc/include/asm/mmzone.h
> @@ -38,13 +38,6 @@ u64 memory_hotplug_max(void);
> #define memory_hotplug_max() memblock_end_of_DRAM()
> #endif
>
> -/*
> - * Following are macros that each numa implmentation must define.
> - */
> -
> -#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
> -#define node_end_pfn(nid) (NODE_DATA(nid)->node_end_pfn)
> -
> #else
> #define memory_hotplug_max() memblock_end_of_DRAM()
> #endif /* CONFIG_NEED_MULTIPLE_NODES */
> diff --git a/arch/sh/include/asm/mmzone.h b/arch/sh/include/asm/mmzone.h
> index 8887baf..15a8496 100644
> --- a/arch/sh/include/asm/mmzone.h
> +++ b/arch/sh/include/asm/mmzone.h
> @@ -9,10 +9,6 @@
> extern struct pglist_data *node_data[];
> #define NODE_DATA(nid) (node_data[nid])
>
> -#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
> -#define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \
> - NODE_DATA(nid)->node_spanned_pages)
> -
> static inline int pfn_to_nid(unsigned long pfn)
> {
> int nid;
> diff --git a/arch/sparc/include/asm/mmzone.h b/arch/sparc/include/asm/mmzone.h
> index e8c6487..99d9b9f 100644
> --- a/arch/sparc/include/asm/mmzone.h
> +++ b/arch/sparc/include/asm/mmzone.h
> @@ -8,8 +8,6 @@
> extern struct pglist_data *node_data[];
>
> #define NODE_DATA(nid) (node_data[nid])
> -#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
> -#define node_end_pfn(nid) (NODE_DATA(nid)->node_end_pfn)
>
> extern int numa_cpu_lookup_table[];
> extern cpumask_t numa_cpumask_lookup_table[];
> diff --git a/arch/tile/include/asm/mmzone.h b/arch/tile/include/asm/mmzone.h
> index c6344c4..9d3dbce 100644
> --- a/arch/tile/include/asm/mmzone.h
> +++ b/arch/tile/include/asm/mmzone.h
> @@ -40,17 +40,6 @@ static inline int pfn_to_nid(unsigned long pfn)
> return highbits_to_node[__pfn_to_highbits(pfn)];
> }
>
> -/*
> - * Following are macros that each numa implmentation must define.
> - */
> -
> -#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
> -#define node_end_pfn(nid) \
> -({ \
> - pg_data_t *__pgdat = NODE_DATA(nid); \
> - __pgdat->node_start_pfn + __pgdat->node_spanned_pages; \
> -})
> -
> #define kern_addr_valid(kaddr) virt_addr_valid((void *)kaddr)
>
> static inline int pfn_valid(int pfn)
> diff --git a/arch/x86/include/asm/mmzone_32.h b/arch/x86/include/asm/mmzone_32.h
> index 5e83a41..224e8c5 100644
> --- a/arch/x86/include/asm/mmzone_32.h
> +++ b/arch/x86/include/asm/mmzone_32.h
> @@ -48,17 +48,6 @@ static inline int pfn_to_nid(unsigned long pfn)
> #endif
> }
>
> -/*
> - * Following are macros that each numa implmentation must define.
> - */
> -
> -#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
> -#define node_end_pfn(nid) \
> -({ \
> - pg_data_t *__pgdat = NODE_DATA(nid); \
> - __pgdat->node_start_pfn + __pgdat->node_spanned_pages; \
> -})
> -
> static inline int pfn_valid(int pfn)
> {
> int nid = pfn_to_nid(pfn);
> diff --git a/arch/x86/include/asm/mmzone_64.h b/arch/x86/include/asm/mmzone_64.h
> index b3f88d7..129d9aa 100644
> --- a/arch/x86/include/asm/mmzone_64.h
> +++ b/arch/x86/include/asm/mmzone_64.h
> @@ -13,8 +13,5 @@ extern struct pglist_data *node_data[];
>
> #define NODE_DATA(nid) (node_data[nid])
>
> -#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
> -#define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \
> - NODE_DATA(nid)->node_spanned_pages)
> #endif
> #endif /* _ASM_X86_MMZONE_64_H */
> diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
> index c928dac..9f7c3eb 100644
> --- a/include/linux/mmzone.h
> +++ b/include/linux/mmzone.h
> @@ -647,6 +647,13 @@ typedef struct pglist_data {
> #endif
> #define nid_page_nr(nid, pagenr) pgdat_page_nr(NODE_DATA(nid),(pagenr))
>
> +#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
> +
> +#define node_end_pfn(nid) ({\
> + pg_data_t *__pgdat = NODE_DATA(nid);\
> + __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\
> +})
> +
> #include <linux/memory_hotplug.h>
>
> extern struct mutex zonelists_mutex;


--
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

2011-06-20 16:38:53

by Ingo Molnar

[permalink] [raw]
Subject: Re: [BUGFIX][PATCH][-rc3] Define a consolidated definition of node_start/end_pfn for build error in page_cgroup.c (Was Re: mmotm 2011-06-15-16-56 uploaded (mm/page_cgroup.c)


* KAMEZAWA Hiroyuki <[email protected]> wrote:

> On Thu, 16 Jun 2011 11:35:59 +0100
> Mel Gorman <[email protected]> wrote:
>
> > A caller that does node_end_pfn(nid++) will get a nasty surprise
> > due to side-effects. I know architectures currently get this wrong
> > including x86_64 but we might as well fix it up now. The definition
> > in arch/x86/include/asm/mmzone_32.h is immune to side-effects and
> > might be a better choice despite the use of a temporary variable.
> >
>
> Ok, here is a fixed one. Thank you for comments/review.
> ==
> >From 507cc95c5ba2351bff16c5421255d1395a3b555b Mon Sep 17 00:00:00 2001
> From: KAMEZAWA Hiroyuki <[email protected]>
> Date: Thu, 16 Jun 2011 17:28:07 +0900
> Subject: [PATCH] Fix node_start/end_pfn() definition for mm/page_cgroup.c
>
> commit 21a3c96 uses node_start/end_pfn(nid) for detection start/end
> of nodes. But, it's not defined in linux/mmzone.h but defined in
> /arch/???/include/mmzone.h which is included only under
> CONFIG_NEED_MULTIPLE_NODES=y.
>
> Then, we see
> mm/page_cgroup.c: In function 'page_cgroup_init':
> mm/page_cgroup.c:308: error: implicit declaration of function 'node_start_pfn'
> mm/page_cgroup.c:309: error: implicit declaration of function 'node_end_pfn'
>
> So, fixiing page_cgroup.c is an idea...

s/fixing

>
> But node_start_pfn()/node_end_pfn() is a very generic macro and
> should be implemented in the same manner for all archs.
> (m32r has different implementation...)
>
> This patch removes definitions of node_start/end_pfn() in each archs
> and defines a unified one in linux/mmzone.h. It's not under
> CONFIG_NEED_MULTIPLE_NODES, now.
>
> A result of macro expansion is here (mm/page_cgroup.c)
>
> for !NUMA
> start_pfn = ((&contig_page_data)->node_start_pfn);
> end_pfn = ({ pg_data_t *__pgdat = (&contig_page_data); __pgdat->node_start_pfn + __pgdat->node_spanned_pages;});
>
> for NUMA (x86-64)
> start_pfn = ((node_data[nid])->node_start_pfn);
> end_pfn = ({ pg_data_t *__pgdat = (node_data[nid]); __pgdat->node_start_pfn + __pgdat->node_spanned_pages;});
>
>
> Reported-by: Randy Dunlap <[email protected]>
> Reported-by: Ingo Molnar <[email protected]>
> Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>

Your patch solved all the build failures on x86 and on a couple of
cross-builds as well i tried:

Tested-by: Ingo Molnar <[email protected]>

Thanks,

Ingo