Skip to contentSkip to conversation

mmotm 2019-07-24-21-39 uploaded

DISCUSSION [email protected] 5 participants 9 messages Jul 25, 2019 – Jul 28, 2019

Subsystems (4)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

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

#1 lore raw

Re: mmotm 2019-07-24-21-39 uploaded (mm/memcontrol)

Quoted 8 lines · On 7/24/19 9:40 PM, [email protected] 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:

Quoted 9 lines

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'

Signature · 1 line
~Randy
author maintainer
#2 lore raw

Re: mmotm 2019-07-24-21-39 uploaded (mm/memcontrol)

Quoted 19 lines · On Thu, 25 Jul 2019 15:02:59 -0700 Randy Dunlap <[email protected]> wrote:
Quoted 8 lines · On 7/24/19 9:40 PM, [email protected] 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:

Quoted 9 lines

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

Quoted 4 lines

on i386:

ld: mm/memcontrol.o: in function `mem_cgroup_handle_over_high':
memcontrol.c:(.text+0x6235): undefined reference to `__udivdi3'

Thanks. This?

mm/memcontrol.c renamed from mm/memcontrol.c~mm-throttle-allocators-when-failing-reclaim-over-memoryhigh-fix-fix +3 -2
@@ -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);
 

_

Acked-by
#3 lore raw

Re: mmotm 2019-07-24-21-39 uploaded (mm/memcontrol)

Quoted 21 lines · Andrew Morton
Quoted 19 lines · On Thu, 25 Jul 2019 15:02:59 -0700 Randy Dunlap <[email protected]> wrote:
Quoted 17 lines · On 7/24/19 9:40 PM, [email protected] 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

Quoted 6 lines
Quoted 4 lines

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.

Quoted 16 lines
mm/memcontrol.c renamed from mm/memcontrol.c~mm-throttle-allocators-when-failing-reclaim-over-memoryhigh-fix-fix +3 -2
@@ -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);
 

_

Signature · 1 line
~Randy
#4 lore raw

Re: mmotm 2019-07-24-21-39 uploaded (mm/memcontrol)

In reply to Andrew Morton
Quoted 42 lines · Andrew Morton
Quoted 19 lines · On Thu, 25 Jul 2019 15:02:59 -0700 Randy Dunlap <[email protected]> wrote:
Quoted 8 lines · On 7/24/19 9:40 PM, [email protected] 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:

Quoted 9 lines

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

Quoted 4 lines

on i386:

ld: mm/memcontrol.o: in function `mem_cgroup_handle_over_high':
memcontrol.c:(.text+0x6235): undefined reference to `__udivdi3'

Thanks. This?

mm/memcontrol.c renamed from mm/memcontrol.c~mm-throttle-allocators-when-failing-reclaim-over-memoryhigh-fix-fix +3 -2
@@ -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);
 
Quoted 2 lines

_

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.

mm/memcontrol.c +2 -2
index 5c7b9facb0eb..04b621f1cb6b 100644
@@ -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);
author maintainer
#5 lore raw

Re: mmotm 2019-07-24-21-39 uploaded (mm/memcontrol)

Quoted 12 lines · On Fri, 26 Jul 2019 20:42:05 -0700 Nathan Chancellor…
Quoted 12 lines
(quoted diff) +3 -2
@@ -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);
 
Quoted 5 lines
Quoted 2 lines

_

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?

mm/memcontrol.c renamed from mm/memcontrol.c~mm-throttle-allocators-when-failing-reclaim-over-memoryhigh-fix-fix-fix +1 -1
@@ -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);

_

#6 lore raw

Re: mmotm 2019-07-24-21-39 uploaded (mm/memcontrol)

Quoted 20 lines · Andrew Morton
Quoted 12 lines · On Fri, 26 Jul 2019 20:42:05 -0700 Nathan Chancellor…
Quoted 12 lines
(quoted diff) +3 -2
@@ -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);
 
Quoted 5 lines
Quoted 2 lines

_

This causes a build error on arm:

Quoted 4 lines

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.

Quoted 13 lines

Chris, please take a look?

mm/memcontrol.c renamed from mm/memcontrol.c~mm-throttle-allocators-when-failing-reclaim-over-memoryhigh-fix-fix-fix +1 -1
@@ -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);
Quoted 2 lines

_

I assume this will get folded in with the original patch but for completeness (multi_v7_defconfig + CONFIG_MEMCG):

Thanks for the quick fix!

#7 lore raw

Re: mmotm 2019-07-24-21-39 uploaded (mm/memcontrol)

In reply to Andrew Morton

u64 division: truly the gift that keeps on giving. Thanks Andrew for following up on these.

Quoted 4 lines · Andrew Morton

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.

mm/memcontrol.c void mem_cgroup_handle_over_high(void) · line 2418

Quoted 10 lines

Chris, please take a look?

mm/memcontrol.c renamed from mm/memcontrol.c~mm-throttle-allocators-when-failing-reclaim-over-memoryhigh-fix-fix-fix +1 -1
@@ -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.

memcontrol.c +2 -2
index 5c7b9facb0eb..e12a47e96154 100644
@@ -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);
#8 lore raw

Re: mmotm 2019-07-24-21-39 uploaded (mm/memcontrol)

Hi all,

Quoted 38 lines · On Sat, 27 Jul 2019 11:16:08 +0100 Chris Down <[email protected]> wrote:

u64 division: truly the gift that keeps on giving. Thanks Andrew for following up on these.

Quoted 4 lines · Andrew Morton

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.

mm/memcontrol.c void mem_cgroup_handle_over_high(void) · line 2418

Quoted 10 lines

Chris, please take a look?

mm/memcontrol.c renamed from mm/memcontrol.c~mm-throttle-allocators-when-failing-reclaim-over-memoryhigh-fix-fix-fix +1 -1
@@ -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.

memcontrol.c +0 -0
index 5c7b9facb0eb..e12a47e96154 100644

memcontrol.c void mem_cgroup_handle_over_high(void) · line 2426

Quoted 10 lines
memcontrol.c +2 -2
@@ -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.

Signature · 2 lines
Cheers,
Stephen Rothwell