* mmotm 2019-07-24-21-39 uploaded @ 2019-07-25 4:40 akpm 2019-07-25 22:02 ` mmotm 2019-07-24-21-39 uploaded (mm/memcontrol) Randy Dunlap 0 siblings, 1 reply; 9+ messages in thread From: akpm @ 2019-07-25 4:40 UTC (permalink / raw) To: broonie, linux-fsdevel, linux-kernel, linux-mm, linux-next, mhocko, mm-commits, sfr The mm-of-the-moment snapshot 2019-07-24-21-39 has been uploaded to http://www.ozlabs.org/~akpm/mmotm/ mmotm-readme.txt says README for mm-of-the-moment: http://www.ozlabs.org/~akpm/mmotm/ This is a snapshot of my -mm patch queue. Uploaded at random hopefully more than once a week. You will need quilt to apply these patches to the latest Linus release (5.x or 5.x-rcY). The series file is in broken-out.tar.gz and is duplicated in http://ozlabs.org/~akpm/mmotm/series The file broken-out.tar.gz contains two datestamp files: .DATE and .DATE-yyyy-mm-dd-hh-mm-ss. Both contain the string yyyy-mm-dd-hh-mm-ss, followed by the base kernel version against which this patch series is to be applied. This tree is partially included in linux-next. To see which patches are included in linux-next, consult the `series' file. Only the patches within the #NEXT_PATCHES_START/#NEXT_PATCHES_END markers are included in linux-next. A full copy of the full kernel tree with the linux-next and mmotm patches already applied is available through git within an hour of the mmotm release. Individual mmotm releases are tagged. The master branch always points to the latest release, so it's constantly rebasing. http://git.cmpxchg.org/cgit.cgi/linux-mmotm.git/ The directory http://www.ozlabs.org/~akpm/mmots/ (mm-of-the-second) contains daily snapshots of the -mm tree. It is updated more frequently than mmotm, and is untested. A git copy of this tree is available at http://git.cmpxchg.org/cgit.cgi/linux-mmots.git/ and use of this tree is similar to http://git.cmpxchg.org/cgit.cgi/linux-mmotm.git/, described above. This mmotm tree contains the following patches against 5.3-rc1: (patches marked "*" will be included in linux-next) origin.patch * docs-signal-fix-a-kernel-doc-markup.patch * revert-kmemleak-allow-to-coexist-with-fault-injection.patch * ocfs2-remove-set-but-not-used-variable-last_hash.patch * mm-vmscan-check-if-mem-cgroup-is-disabled-or-not-before-calling-memcg-slab-shrinker.patch * mm-migrate-fix-reference-check-race-between-__find_get_block-and-migration.patch * mm-compaction-avoid-100%-cpu-usage-during-compaction-when-a-task-is-killed.patch * kasan-remove-clang-version-check-for-kasan_stack.patch * proc-kpageflags-prevent-an-integer-overflow-in-stable_page_flags.patch * proc-kpageflags-do-not-use-uninitialized-struct-pages.patch * mm-document-zone-device-struct-page-field-usage.patch * mm-hmm-fix-zone_device-anon-page-mapping-reuse.patch * mm-hmm-fix-bad-subpage-pointer-in-try_to_unmap_one.patch * mm-hmm-fix-bad-subpage-pointer-in-try_to_unmap_one-v3.patch * ubsan-build-ubsanc-more-conservatively.patch * page-flags-prioritize-kasan-bits-over-last-cpuid.patch * coredump-split-pipe-command-whitespace-before-expanding-template.patch * mm-migrate-initialize-pud_entry-in-migrate_vma.patch * mm-hotplug-remove-unneeded-return-for-void-function.patch * cgroup-kselftest-relax-fs_spec-checks.patch * asm-generic-fix-wtype-limits-compiler-warnings.patch * asm-generic-fix-wtype-limits-compiler-warnings-fix.patch * asm-generic-fix-wtype-limits-compiler-warnings-v2.patch * acpi-scan-acquire-device_hotplug_lock-in-acpi_scan_init.patch * mm-mempolicy-make-the-behavior-consistent-when-mpol_mf_move-and-mpol_mf_strict-were-specified.patch * mm-mempolicy-make-the-behavior-consistent-when-mpol_mf_move-and-mpol_mf_strict-were-specified-v4.patch * mm-mempolicy-handle-vma-with-unmovable-pages-mapped-correctly-in-mbind.patch * mm-mempolicy-handle-vma-with-unmovable-pages-mapped-correctly-in-mbind-v4.patch * kbuild-clean-compressed-initramfs-image.patch * ocfs2-use-jbd2_inode-dirty-range-scoping.patch * jbd2-remove-jbd2_journal_inode_add_.patch * ocfs2-clear-zero-in-unaligned-direct-io.patch * ocfs2-clear-zero-in-unaligned-direct-io-checkpatch-fixes.patch * ocfs2-wait-for-recovering-done-after-direct-unlock-request.patch * ocfs2-checkpoint-appending-truncate-log-transaction-before-flushing.patch * ramfs-support-o_tmpfile.patch mm.patch * mm-slab-extend-slab-shrink-to-shrink-all-memcg-caches.patch * mm-slab-move-memcg_cache_params-structure-to-mm-slabh.patch * memremap-move-from-kernel-to-mm.patch * mm-page_poison-fix-a-typo-in-a-comment.patch * mm-rmapc-remove-set-but-not-used-variable-cstart.patch * mm-introduce-page_size.patch * mm-introduce-page_shift.patch * mm-introduce-page_shift-fix.patch * mm-introduce-compound_nr.patch * mm-replace-list_move_tail-with-add_page_to_lru_list_tail.patch * mm-filemap-rewrite-mapping_needs_writeback-in-less-fancy-manner.patch * mm-throttle-allocators-when-failing-reclaim-over-memoryhigh.patch * mm-throttle-allocators-when-failing-reclaim-over-memoryhigh-fix.patch * mm-vmscan-expose-cgroup_ino-for-memcg-reclaim-tracepoints.patch * mm-gup-add-make_dirty-arg-to-put_user_pages_dirty_lock.patch * drivers-gpu-drm-via-convert-put_page-to-put_user_page.patch * net-xdp-convert-put_page-to-put_user_page.patch * mm-remove-redundant-assignment-of-entry.patch * mm-mmap-fix-the-adjusted-length-error.patch * mm-memory_hotplug-remove-move_pfn_range.patch * mm-memory_hotplug-remove-move_pfn_range-fix.patch * drivers-base-nodec-simplify-unregister_memory_block_under_nodes.patch * mm-sparse-fix-memory-leak-of-sparsemap_buf-in-aliged-memory.patch * mm-sparse-fix-memory-leak-of-sparsemap_buf-in-aliged-memory-fix.patch * mm-sparse-fix-align-without-power-of-2-in-sparse_buffer_alloc.patch * mm-vmalloc-do-not-keep-unpurged-areas-in-the-busy-tree.patch * mm-vmalloc-modify-struct-vmap_area-to-reduce-its-size.patch * mm-compaction-clear-total_migratefree_scanned-before-scanning-a-new-zone.patch * mm-compaction-clear-total_migratefree_scanned-before-scanning-a-new-zone-fix.patch * mm-compaction-clear-total_migratefree_scanned-before-scanning-a-new-zone-fix-fix.patch * mm-compaction-clear-total_migratefree_scanned-before-scanning-a-new-zone-fix-2.patch * mm-compaction-clear-total_migratefree_scanned-before-scanning-a-new-zone-fix-2-fix.patch * mm-oom-avoid-printk-iteration-under-rcu.patch * mm-oom-avoid-printk-iteration-under-rcu-fix.patch * mm-oom_killer-add-task-uid-to-info-message-on-an-oom-kill.patch * mm-oom_killer-add-task-uid-to-info-message-on-an-oom-kill-fix.patch * psi-annotate-refault-stalls-from-io-submission.patch * psi-annotate-refault-stalls-from-io-submission-fix.patch * psi-annotate-refault-stalls-from-io-submission-fix-2.patch * mm-introduce-madv_cold.patch * mm-change-pageref_reclaim_clean-with-page_refreclaim.patch * mm-account-nr_isolated_xxx-in-_lru_page.patch * mm-introduce-madv_pageout.patch * mm-factor-out-common-parts-between-madv_cold-and-madv_pageout.patch * zpool-add-malloc_support_movable-to-zpool_driver.patch * zswap-use-movable-memory-if-zpool-support-allocate-movable-memory.patch * mm-proportional-memorylowmin-reclaim.patch * mm-make-memoryemin-the-baseline-for-utilisation-determination.patch * mm-make-memoryemin-the-baseline-for-utilisation-determination-fix.patch * mm-vmscan-remove-unused-lru_pages-argument.patch * mm-dont-expose-page-to-fast-gup-before-its-ready.patch * info-task-hung-in-generic_file_write_iter.patch * info-task-hung-in-generic_file_write-fix.patch * kernel-hung_taskc-monitor-killed-tasks.patch * hung_task-allow-printing-warnings-every-check-interval.patch * lib-genallocc-export-symbol-addr_in_gen_pool.patch * lib-genallocc-rename-addr_in_gen_pool-to-gen_pool_has_addr.patch * lib-genallocc-rename-addr_in_gen_pool-to-gen_pool_has_addr-fix.patch * string-add-stracpy-and-stracpy_pad-mechanisms.patch * kernel-doc-core-api-include-stringh-into-core-api.patch * kernel-doc-core-api-include-stringh-into-core-api-v2.patch * lib-fix-possible-incorrect-result-from-rational-fractions-helper.patch * checkpatch-dont-interpret-stack-dumps-as-commit-ids.patch * checkpatch-improve-spdx-license-checking.patch * checkpatchpl-warn-on-invalid-commit-id.patch * checkpatch-add-_notifier_head-as-var-definition.patch * fat-add-nobarrier-to-workaround-the-strange-behavior-of-device.patch * cpumask-nicer-for_each_cpumask_and-signature.patch * kexec-bail-out-upon-sigkill-when-allocating-memory.patch * aio-simplify-read_events.patch * kgdb-dont-use-a-notifier-to-enter-kgdb-at-panic-call-directly.patch * ipc-consolidate-all-xxxctl_down-functions.patch linux-next.patch diff-sucks.patch * pinctrl-fix-pxa2xxc-build-warnings.patch * mm-treewide-clarify-pgtable_page_ctordtor-naming.patch * drivers-tty-serial-sh-scic-suppress-warning.patch * fix-read-buffer-overflow-in-delta-ipc.patch make-sure-nobodys-leaking-resources.patch releasing-resources-with-children.patch mutex-subsystem-synchro-test-module.patch kernel-forkc-export-kernel_thread-to-modules.patch workaround-for-a-pci-restoring-bug.patch ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: mmotm 2019-07-24-21-39 uploaded (mm/memcontrol) 2019-07-25 4:40 mmotm 2019-07-24-21-39 uploaded akpm @ 2019-07-25 22:02 ` Randy Dunlap 2019-07-25 23:39 ` Andrew Morton 0 siblings, 1 reply; 9+ messages in thread From: Randy Dunlap @ 2019-07-25 22:02 UTC (permalink / raw) To: akpm, broonie, linux-fsdevel, linux-kernel, linux-mm, linux-next, mhocko, mm-commits, sfr, Chris Down On 7/24/19 9:40 PM, akpm@linux-foundation.org wrote: > The mm-of-the-moment snapshot 2019-07-24-21-39 has been uploaded to > > http://www.ozlabs.org/~akpm/mmotm/ > > mmotm-readme.txt says > > README for mm-of-the-moment: > > http://www.ozlabs.org/~akpm/mmotm/ > > This is a snapshot of my -mm patch queue. Uploaded at random hopefully > more than once a week. > > You will need quilt to apply these patches to the latest Linus release (5.x > or 5.x-rcY). The series file is in broken-out.tar.gz and is duplicated in > http://ozlabs.org/~akpm/mmotm/series > on i386: ld: mm/memcontrol.o: in function `mem_cgroup_handle_over_high': memcontrol.c:(.text+0x6235): undefined reference to `__udivdi3' -- ~Randy ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: mmotm 2019-07-24-21-39 uploaded (mm/memcontrol) 2019-07-25 22:02 ` mmotm 2019-07-24-21-39 uploaded (mm/memcontrol) Randy Dunlap @ 2019-07-25 23:39 ` Andrew Morton 2019-07-25 23:51 ` Randy Dunlap 2019-07-27 3:42 ` Nathan Chancellor 0 siblings, 2 replies; 9+ messages in thread From: Andrew Morton @ 2019-07-25 23:39 UTC (permalink / raw) To: Randy Dunlap Cc: broonie, linux-fsdevel, linux-kernel, linux-mm, linux-next, mhocko, mm-commits, sfr, Chris Down On Thu, 25 Jul 2019 15:02:59 -0700 Randy Dunlap <rdunlap@infradead.org> wrote: > On 7/24/19 9:40 PM, akpm@linux-foundation.org wrote: > > The mm-of-the-moment snapshot 2019-07-24-21-39 has been uploaded to > > > > http://www.ozlabs.org/~akpm/mmotm/ > > > > mmotm-readme.txt says > > > > README for mm-of-the-moment: > > > > http://www.ozlabs.org/~akpm/mmotm/ > > > > This is a snapshot of my -mm patch queue. Uploaded at random hopefully > > more than once a week. > > > > You will need quilt to apply these patches to the latest Linus release (5.x > > or 5.x-rcY). The series file is in broken-out.tar.gz and is duplicated in > > http://ozlabs.org/~akpm/mmotm/series > > > > on i386: > > ld: mm/memcontrol.o: in function `mem_cgroup_handle_over_high': > memcontrol.c:(.text+0x6235): undefined reference to `__udivdi3' Thanks. This? --- a/mm/memcontrol.c~mm-throttle-allocators-when-failing-reclaim-over-memoryhigh-fix-fix +++ a/mm/memcontrol.c @@ -2414,8 +2414,9 @@ void mem_cgroup_handle_over_high(void) */ clamped_high = max(high, 1UL); - overage = ((u64)(usage - high) << MEMCG_DELAY_PRECISION_SHIFT) - / clamped_high; + overage = (u64)(usage - high) << MEMCG_DELAY_PRECISION_SHIFT; + do_div(overage, clamped_high); + penalty_jiffies = ((u64)overage * overage * HZ) >> (MEMCG_DELAY_PRECISION_SHIFT + MEMCG_DELAY_SCALING_SHIFT); _ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: mmotm 2019-07-24-21-39 uploaded (mm/memcontrol) 2019-07-25 23:39 ` Andrew Morton @ 2019-07-25 23:51 ` Randy Dunlap 2019-07-27 3:42 ` Nathan Chancellor 1 sibling, 0 replies; 9+ messages in thread From: Randy Dunlap @ 2019-07-25 23:51 UTC (permalink / raw) To: Andrew Morton Cc: broonie, linux-fsdevel, linux-kernel, linux-mm, linux-next, mhocko, mm-commits, sfr, Chris Down On 7/25/19 4:39 PM, Andrew Morton wrote: > On Thu, 25 Jul 2019 15:02:59 -0700 Randy Dunlap <rdunlap@infradead.org> wrote: > >> On 7/24/19 9:40 PM, akpm@linux-foundation.org wrote: >>> The mm-of-the-moment snapshot 2019-07-24-21-39 has been uploaded to >>> >>> http://www.ozlabs.org/~akpm/mmotm/ >>> >>> mmotm-readme.txt says >>> >>> README for mm-of-the-moment: >>> >>> http://www.ozlabs.org/~akpm/mmotm/ >>> >>> This is a snapshot of my -mm patch queue. Uploaded at random hopefully >>> more than once a week. >>> >>> You will need quilt to apply these patches to the latest Linus release (5.x >>> or 5.x-rcY). The series file is in broken-out.tar.gz and is duplicated in >>> http://ozlabs.org/~akpm/mmotm/series >>> >> >> on i386: >> >> ld: mm/memcontrol.o: in function `mem_cgroup_handle_over_high': >> memcontrol.c:(.text+0x6235): undefined reference to `__udivdi3' > > Thanks. This? Yes, that works. Thanks. Acked-by: Randy Dunlap <rdunlap@infradead.org> > --- a/mm/memcontrol.c~mm-throttle-allocators-when-failing-reclaim-over-memoryhigh-fix-fix > +++ a/mm/memcontrol.c > @@ -2414,8 +2414,9 @@ void mem_cgroup_handle_over_high(void) > */ > clamped_high = max(high, 1UL); > > - overage = ((u64)(usage - high) << MEMCG_DELAY_PRECISION_SHIFT) > - / clamped_high; > + overage = (u64)(usage - high) << MEMCG_DELAY_PRECISION_SHIFT; > + do_div(overage, clamped_high); > + > penalty_jiffies = ((u64)overage * overage * HZ) > >> (MEMCG_DELAY_PRECISION_SHIFT + MEMCG_DELAY_SCALING_SHIFT); > > _ > -- ~Randy ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: mmotm 2019-07-24-21-39 uploaded (mm/memcontrol) 2019-07-25 23:39 ` Andrew Morton 2019-07-25 23:51 ` Randy Dunlap @ 2019-07-27 3:42 ` Nathan Chancellor 2019-07-27 4:19 ` Andrew Morton 1 sibling, 1 reply; 9+ messages in thread From: Nathan Chancellor @ 2019-07-27 3:42 UTC (permalink / raw) To: Andrew Morton Cc: Randy Dunlap, broonie, linux-fsdevel, linux-kernel, linux-mm, linux-next, mhocko, mm-commits, sfr, Chris Down On Thu, Jul 25, 2019 at 04:39:59PM -0700, Andrew Morton wrote: > On Thu, 25 Jul 2019 15:02:59 -0700 Randy Dunlap <rdunlap@infradead.org> wrote: > > > On 7/24/19 9:40 PM, akpm@linux-foundation.org wrote: > > > The mm-of-the-moment snapshot 2019-07-24-21-39 has been uploaded to > > > > > > http://www.ozlabs.org/~akpm/mmotm/ > > > > > > mmotm-readme.txt says > > > > > > README for mm-of-the-moment: > > > > > > http://www.ozlabs.org/~akpm/mmotm/ > > > > > > This is a snapshot of my -mm patch queue. Uploaded at random hopefully > > > more than once a week. > > > > > > You will need quilt to apply these patches to the latest Linus release (5.x > > > or 5.x-rcY). The series file is in broken-out.tar.gz and is duplicated in > > > http://ozlabs.org/~akpm/mmotm/series > > > > > > > on i386: > > > > ld: mm/memcontrol.o: in function `mem_cgroup_handle_over_high': > > memcontrol.c:(.text+0x6235): undefined reference to `__udivdi3' > > Thanks. This? > > --- a/mm/memcontrol.c~mm-throttle-allocators-when-failing-reclaim-over-memoryhigh-fix-fix > +++ a/mm/memcontrol.c > @@ -2414,8 +2414,9 @@ void mem_cgroup_handle_over_high(void) > */ > clamped_high = max(high, 1UL); > > - overage = ((u64)(usage - high) << MEMCG_DELAY_PRECISION_SHIFT) > - / clamped_high; > + overage = (u64)(usage - high) << MEMCG_DELAY_PRECISION_SHIFT; > + do_div(overage, clamped_high); > + > penalty_jiffies = ((u64)overage * overage * HZ) > >> (MEMCG_DELAY_PRECISION_SHIFT + MEMCG_DELAY_SCALING_SHIFT); > > _ > This causes a build error on arm: In file included from ../arch/arm/include/asm/div64.h:127, from ../include/linux/kernel.h:18, from ../include/linux/page_counter.h:6, from ../mm/memcontrol.c:25: ../mm/memcontrol.c: In function 'mem_cgroup_handle_over_high': ../include/asm-generic/div64.h:222:28: warning: comparison of distinct pointer types lacks a cast 222 | (void)(((typeof((n)) *)0) == ((uint64_t *)0)); \ | ^~ ../mm/memcontrol.c:2423:2: note: in expansion of macro 'do_div' 2423 | do_div(overage, clamped_high); | ^~~~~~ In file included from ../arch/arm/include/asm/atomic.h:11, from ../include/linux/atomic.h:7, from ../include/linux/page_counter.h:5, from ../mm/memcontrol.c:25: ../include/asm-generic/div64.h:235:25: warning: right shift count >= width of type [-Wshift-count-overflow] 235 | } else if (likely(((n) >> 32) == 0)) { \ | ^~ ../include/linux/compiler.h:77:40: note: in definition of macro 'likely' 77 | # define likely(x) __builtin_expect(!!(x), 1) | ^ ../mm/memcontrol.c:2423:2: note: in expansion of macro 'do_div' 2423 | do_div(overage, clamped_high); | ^~~~~~ In file included from ../arch/arm/include/asm/div64.h:127, from ../include/linux/kernel.h:18, from ../include/linux/page_counter.h:6, from ../mm/memcontrol.c:25: ../include/asm-generic/div64.h:239:22: error: passing argument 1 of '__div64_32' from incompatible pointer type [-Werror=incompatible-pointer-types] 239 | __rem = __div64_32(&(n), __base); \ | ^~~~ | | | long unsigned int * ../mm/memcontrol.c:2423:2: note: in expansion of macro 'do_div' 2423 | do_div(overage, clamped_high); | ^~~~~~ In file included from ../include/linux/kernel.h:18, from ../include/linux/page_counter.h:6, from ../mm/memcontrol.c:25: ../arch/arm/include/asm/div64.h:33:45: note: expected 'uint64_t *' {aka 'long long unsigned int *'} but argument is of type 'long unsigned int *' 33 | static inline uint32_t __div64_32(uint64_t *n, uint32_t base) | ~~~~~~~~~~^ cc1: some warnings being treated as errors make[3]: *** [../scripts/Makefile.build:274: mm/memcontrol.o] Error 1 make[2]: *** [../Makefile:1768: mm/memcontrol.o] Error 2 make[1]: *** [/home/nathan/cbl/linux-next/Makefile:330: __build_one_by_one] Error 2 make: *** [Makefile:179: sub-make] Error 2 I fixed it up like so but no idea if that is the ideal function to use. diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 5c7b9facb0eb..04b621f1cb6b 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2419,8 +2419,8 @@ void mem_cgroup_handle_over_high(void) */ clamped_high = max(high, 1UL); - overage = (u64)(usage - high) << MEMCG_DELAY_PRECISION_SHIFT; - do_div(overage, clamped_high); + overage = div64_u64((u64)(usage - high) << MEMCG_DELAY_PRECISION_SHIFT, + clamped_high); penalty_jiffies = ((u64)overage * overage * HZ) >> (MEMCG_DELAY_PRECISION_SHIFT + MEMCG_DELAY_SCALING_SHIFT); ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: mmotm 2019-07-24-21-39 uploaded (mm/memcontrol) 2019-07-27 3:42 ` Nathan Chancellor @ 2019-07-27 4:19 ` Andrew Morton 2019-07-27 4:36 ` Nathan Chancellor 2019-07-27 10:16 ` Chris Down 0 siblings, 2 replies; 9+ messages in thread From: Andrew Morton @ 2019-07-27 4:19 UTC (permalink / raw) To: Nathan Chancellor Cc: Randy Dunlap, broonie, linux-fsdevel, linux-kernel, linux-mm, linux-next, mhocko, mm-commits, sfr, Chris Down On Fri, 26 Jul 2019 20:42:05 -0700 Nathan Chancellor <natechancellor@gmail.com> wrote: > > @@ -2414,8 +2414,9 @@ void mem_cgroup_handle_over_high(void) > > */ > > clamped_high = max(high, 1UL); > > > > - overage = ((u64)(usage - high) << MEMCG_DELAY_PRECISION_SHIFT) > > - / clamped_high; > > + overage = (u64)(usage - high) << MEMCG_DELAY_PRECISION_SHIFT; > > + do_div(overage, clamped_high); > > + > > penalty_jiffies = ((u64)overage * overage * HZ) > > >> (MEMCG_DELAY_PRECISION_SHIFT + MEMCG_DELAY_SCALING_SHIFT); > > > > _ > > > > This causes a build error on arm: > Ah. It's rather unclear why that u64 cast is there anyway. We're dealing with ulongs all over this code. The below will suffice. Chris, please take a look? --- a/mm/memcontrol.c~mm-throttle-allocators-when-failing-reclaim-over-memoryhigh-fix-fix-fix +++ a/mm/memcontrol.c @@ -2415,7 +2415,7 @@ void mem_cgroup_handle_over_high(void) clamped_high = max(high, 1UL); overage = (u64)(usage - high) << MEMCG_DELAY_PRECISION_SHIFT; - do_div(overage, clamped_high); + overage /= clamped_high; penalty_jiffies = ((u64)overage * overage * HZ) >> (MEMCG_DELAY_PRECISION_SHIFT + MEMCG_DELAY_SCALING_SHIFT); _ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: mmotm 2019-07-24-21-39 uploaded (mm/memcontrol) 2019-07-27 4:19 ` Andrew Morton @ 2019-07-27 4:36 ` Nathan Chancellor 2019-07-27 10:16 ` Chris Down 1 sibling, 0 replies; 9+ messages in thread From: Nathan Chancellor @ 2019-07-27 4:36 UTC (permalink / raw) To: Andrew Morton Cc: Randy Dunlap, broonie, linux-fsdevel, linux-kernel, linux-mm, linux-next, mhocko, mm-commits, sfr, Chris Down On Fri, Jul 26, 2019 at 09:19:52PM -0700, Andrew Morton wrote: > On Fri, 26 Jul 2019 20:42:05 -0700 Nathan Chancellor <natechancellor@gmail.com> wrote: > > > > @@ -2414,8 +2414,9 @@ void mem_cgroup_handle_over_high(void) > > > */ > > > clamped_high = max(high, 1UL); > > > > > > - overage = ((u64)(usage - high) << MEMCG_DELAY_PRECISION_SHIFT) > > > - / clamped_high; > > > + overage = (u64)(usage - high) << MEMCG_DELAY_PRECISION_SHIFT; > > > + do_div(overage, clamped_high); > > > + > > > penalty_jiffies = ((u64)overage * overage * HZ) > > > >> (MEMCG_DELAY_PRECISION_SHIFT + MEMCG_DELAY_SCALING_SHIFT); > > > > > > _ > > > > > > > This causes a build error on arm: > > > > Ah. > > It's rather unclear why that u64 cast is there anyway. We're dealing > with ulongs all over this code. The below will suffice. I was thinking the same thing. > Chris, please take a look? > > --- a/mm/memcontrol.c~mm-throttle-allocators-when-failing-reclaim-over-memoryhigh-fix-fix-fix > +++ a/mm/memcontrol.c > @@ -2415,7 +2415,7 @@ void mem_cgroup_handle_over_high(void) > clamped_high = max(high, 1UL); > > overage = (u64)(usage - high) << MEMCG_DELAY_PRECISION_SHIFT; > - do_div(overage, clamped_high); > + overage /= clamped_high; > > penalty_jiffies = ((u64)overage * overage * HZ) > >> (MEMCG_DELAY_PRECISION_SHIFT + MEMCG_DELAY_SCALING_SHIFT); > _ > I assume this will get folded in with the original patch but for completeness (multi_v7_defconfig + CONFIG_MEMCG): Tested-by: Nathan Chancellor <natechancellor@gmail.com> Thanks for the quick fix! ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: mmotm 2019-07-24-21-39 uploaded (mm/memcontrol) 2019-07-27 4:19 ` Andrew Morton 2019-07-27 4:36 ` Nathan Chancellor @ 2019-07-27 10:16 ` Chris Down 2019-07-28 23:51 ` Stephen Rothwell 1 sibling, 1 reply; 9+ messages in thread From: Chris Down @ 2019-07-27 10:16 UTC (permalink / raw) To: Andrew Morton Cc: Nathan Chancellor, Randy Dunlap, broonie, linux-fsdevel, linux-kernel, linux-mm, linux-next, mhocko, mm-commits, sfr u64 division: truly the gift that keeps on giving. Thanks Andrew for following up on these. Andrew Morton writes: >Ah. > >It's rather unclear why that u64 cast is there anyway. We're dealing >with ulongs all over this code. The below will suffice. This place in particular uses u64 to make sure we don't overflow when left shifting, since the numbers can get pretty big (and that's somewhat needed due to the need for high precision when calculating the penalty jiffies). It's ok if the output after division is an unsigned long, just the intermediate steps need to have enough precision. >Chris, please take a look? > >--- a/mm/memcontrol.c~mm-throttle-allocators-when-failing-reclaim-over-memoryhigh-fix-fix-fix >+++ a/mm/memcontrol.c >@@ -2415,7 +2415,7 @@ void mem_cgroup_handle_over_high(void) > clamped_high = max(high, 1UL); > > overage = (u64)(usage - high) << MEMCG_DELAY_PRECISION_SHIFT; >- do_div(overage, clamped_high); >+ overage /= clamped_high; I think this isn't going to work because left shifting by MEMCG_DELAY_PRECISION_SHIFT can make the number bigger than ULONG_MAX, which may cause wraparound -- we need to retain the u64 until we divide. Maybe div_u64 will satisfy both ARM and i386? ie. diff --git mm/memcontrol.c mm/memcontrol.c index 5c7b9facb0eb..e12a47e96154 100644 --- mm/memcontrol.c +++ mm/memcontrol.c @@ -2419,8 +2419,8 @@ void mem_cgroup_handle_over_high(void) */ clamped_high = max(high, 1UL); - overage = (u64)(usage - high) << MEMCG_DELAY_PRECISION_SHIFT; - do_div(overage, clamped_high); + overage = div_u64((u64)(usage - high) << MEMCG_DELAY_PRECISION_SHIFT, + clamped_high); penalty_jiffies = ((u64)overage * overage * HZ) >> (MEMCG_DELAY_PRECISION_SHIFT + MEMCG_DELAY_SCALING_SHIFT); ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: mmotm 2019-07-24-21-39 uploaded (mm/memcontrol) 2019-07-27 10:16 ` Chris Down @ 2019-07-28 23:51 ` Stephen Rothwell 0 siblings, 0 replies; 9+ messages in thread From: Stephen Rothwell @ 2019-07-28 23:51 UTC (permalink / raw) To: Chris Down Cc: Andrew Morton, Nathan Chancellor, Randy Dunlap, broonie, linux-fsdevel, linux-kernel, linux-mm, linux-next, mhocko, mm-commits [-- Attachment #1: Type: text/plain, Size: 2171 bytes --] Hi all, On Sat, 27 Jul 2019 11:16:08 +0100 Chris Down <chris@chrisdown.name> wrote: > > u64 division: truly the gift that keeps on giving. Thanks Andrew for following > up on these. > > Andrew Morton writes: > >Ah. > > > >It's rather unclear why that u64 cast is there anyway. We're dealing > >with ulongs all over this code. The below will suffice. > > This place in particular uses u64 to make sure we don't overflow when left > shifting, since the numbers can get pretty big (and that's somewhat needed due > to the need for high precision when calculating the penalty jiffies). It's ok > if the output after division is an unsigned long, just the intermediate steps > need to have enough precision. > > >Chris, please take a look? > > > >--- a/mm/memcontrol.c~mm-throttle-allocators-when-failing-reclaim-over-memoryhigh-fix-fix-fix > >+++ a/mm/memcontrol.c > >@@ -2415,7 +2415,7 @@ void mem_cgroup_handle_over_high(void) > > clamped_high = max(high, 1UL); > > > > overage = (u64)(usage - high) << MEMCG_DELAY_PRECISION_SHIFT; > >- do_div(overage, clamped_high); > >+ overage /= clamped_high; > > I think this isn't going to work because left shifting by > MEMCG_DELAY_PRECISION_SHIFT can make the number bigger than ULONG_MAX, which > may cause wraparound -- we need to retain the u64 until we divide. > > Maybe div_u64 will satisfy both ARM and i386? ie. > > diff --git mm/memcontrol.c mm/memcontrol.c > index 5c7b9facb0eb..e12a47e96154 100644 > --- mm/memcontrol.c > +++ mm/memcontrol.c > @@ -2419,8 +2419,8 @@ void mem_cgroup_handle_over_high(void) > */ > clamped_high = max(high, 1UL); > > - overage = (u64)(usage - high) << MEMCG_DELAY_PRECISION_SHIFT; > - do_div(overage, clamped_high); > + overage = div_u64((u64)(usage - high) << MEMCG_DELAY_PRECISION_SHIFT, > + clamped_high); > > penalty_jiffies = ((u64)overage * overage * HZ) > >> (MEMCG_DELAY_PRECISION_SHIFT + MEMCG_DELAY_SCALING_SHIFT); I have applied this to the akpm-current tree in linux-next today. -- Cheers, Stephen Rothwell [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2019-07-28 23:51 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-07-25 4:40 mmotm 2019-07-24-21-39 uploaded akpm 2019-07-25 22:02 ` mmotm 2019-07-24-21-39 uploaded (mm/memcontrol) Randy Dunlap 2019-07-25 23:39 ` Andrew Morton 2019-07-25 23:51 ` Randy Dunlap 2019-07-27 3:42 ` Nathan Chancellor 2019-07-27 4:19 ` Andrew Morton 2019-07-27 4:36 ` Nathan Chancellor 2019-07-27 10:16 ` Chris Down 2019-07-28 23:51 ` Stephen Rothwell
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).