linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: akpm@linux-foundation.org, linmiaohe@huawei.com,
	linux-mm@kvack.org, mm-commits@vger.kernel.org,
	torvalds@linux-foundation.org
Subject: [patch 056/156] mm/vmstat.c: use helper macro abs()
Date: Thu, 15 Oct 2020 19:44:24 -0700	[thread overview]
Message-ID: <20201016024424.biNnIIAcg%akpm@linux-foundation.org> (raw)
In-Reply-To: <20201015192732.f448da14e9854c7cb7299956@linux-foundation.org>

From: Miaohe Lin <linmiaohe@huawei.com>
Subject: mm/vmstat.c: use helper macro abs()

Use helper macro abs() to simplify the "x > t || x < -t" cmp.

Link: https://lkml.kernel.org/r/20200905084008.15748-1-linmiaohe@huawei.com
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/vmstat.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

--- a/mm/vmstat.c~mm-vmstat-use-helper-macro-abs
+++ a/mm/vmstat.c
@@ -325,7 +325,7 @@ void __mod_zone_page_state(struct zone *
 
 	t = __this_cpu_read(pcp->stat_threshold);
 
-	if (unlikely(x > t || x < -t)) {
+	if (unlikely(abs(x) > t)) {
 		zone_page_state_add(x, zone, item);
 		x = 0;
 	}
@@ -350,7 +350,7 @@ void __mod_node_page_state(struct pglist
 
 	t = __this_cpu_read(pcp->stat_threshold);
 
-	if (unlikely(x > t || x < -t)) {
+	if (unlikely(abs(x) > t)) {
 		node_page_state_add(x, pgdat, item);
 		x = 0;
 	}
@@ -511,7 +511,7 @@ static inline void mod_zone_state(struct
 		o = this_cpu_read(*p);
 		n = delta + o;
 
-		if (n > t || n < -t) {
+		if (abs(n) > t) {
 			int os = overstep_mode * (t >> 1) ;
 
 			/* Overflow must be added to zone counters */
@@ -573,7 +573,7 @@ static inline void mod_node_state(struct
 		o = this_cpu_read(*p);
 		n = delta + o;
 
-		if (n > t || n < -t) {
+		if (abs(n) > t) {
 			int os = overstep_mode * (t >> 1) ;
 
 			/* Overflow must be added to node counters */
_


  parent reply	other threads:[~2020-10-16  2:44 UTC|newest]

Thread overview: 157+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20201015192732.f448da14e9854c7cb7299956@linux-foundation.org>
2020-10-16  2:40 ` [patch 001/156] device-dax/kmem: fix resource release Andrew Morton
2020-10-16  2:41 ` [patch 002/156] powerpc/mm: add DEBUG_VM WARN for pmd_clear Andrew Morton
2020-10-16  2:41 ` [patch 003/156] powerpc/mm: move setting pte specific flags to pfn_pte Andrew Morton
2020-10-16  2:41 ` [patch 004/156] mm/debug_vm_pgtable/ppc64: avoid setting top bits in radom value Andrew Morton
2020-10-16  2:41 ` [patch 005/156] mm/debug_vm_pgtables/hugevmap: use the arch helper to identify huge vmap support Andrew Morton
2020-10-16  2:41 ` [patch 006/156] mm/debug_vm_pgtable/savedwrite: enable savedwrite test with CONFIG_NUMA_BALANCING Andrew Morton
2020-10-16  2:41 ` [patch 007/156] mm/debug_vm_pgtable/THP: mark the pte entry huge before using set_pmd/pud_at Andrew Morton
2020-10-16  2:41 ` [patch 008/156] mm/debug_vm_pgtable/set_pte/pmd/pud: don't use set_*_at to update an existing pte entry Andrew Morton
2020-10-16  2:41 ` [patch 009/156] mm/debug_vm_pgtable/locks: move non page table modifying test together Andrew Morton
2020-10-16  2:41 ` [patch 010/156] mm/debug_vm_pgtable/locks: take correct page table lock Andrew Morton
2020-10-16  2:41 ` [patch 011/156] mm/debug_vm_pgtable/thp: use page table depost/withdraw with THP Andrew Morton
2020-10-16  2:41 ` [patch 012/156] mm/debug_vm_pgtable/pmd_clear: don't use pmd/pud_clear on pte entries Andrew Morton
2020-10-16  2:41 ` [patch 013/156] mm/debug_vm_pgtable/hugetlb: disable hugetlb test on ppc64 Andrew Morton
2020-10-16  2:41 ` [patch 014/156] mm/debug_vm_pgtable: avoid none pte in pte_clear_test Andrew Morton
2020-10-16  2:41 ` [patch 015/156] mm/debug_vm_pgtable: avoid doing memory allocation with pgtable_t mapped Andrew Morton
2020-10-16  2:41 ` [patch 016/156] XArray: add xa_get_order Andrew Morton
2020-10-16  2:41 ` [patch 017/156] XArray: add xas_split Andrew Morton
2020-10-16  2:41 ` [patch 018/156] mm/filemap: fix storing to a THP shadow entry Andrew Morton
2020-10-16  2:42 ` [patch 019/156] mm/filemap: fix page cache removal for arbitrary sized THPs Andrew Morton
2020-10-16  2:42 ` [patch 020/156] mm/memory: remove page fault assumption of compound page size Andrew Morton
2020-10-16  2:42 ` [patch 021/156] mm/page_owner: change split_page_owner to take a count Andrew Morton
2020-10-16 11:14   ` Matthew Wilcox
2020-10-16  2:42 ` [patch 022/156] mm/huge_memory: fix total_mapcount assumption of page size Andrew Morton
2020-10-16  2:42 ` [patch 023/156] mm/huge_memory: fix split " Andrew Morton
2020-10-16  2:42 ` [patch 024/156] mm/huge_memory: fix page_trans_huge_mapcount assumption of THP size Andrew Morton
2020-10-16  2:42 ` [patch 025/156] mm/huge_memory: fix can_split_huge_page " Andrew Morton
2020-10-16  2:42 ` [patch 026/156] mm/rmap: fix assumptions " Andrew Morton
2020-10-16  2:42 ` [patch 027/156] mm/truncate: fix truncation for pages of arbitrary size Andrew Morton
2020-10-16  2:42 ` [patch 028/156] mm/page-writeback: support tail pages in wait_for_stable_page Andrew Morton
2020-10-16  2:42 ` [patch 029/156] mm/vmscan: allow arbitrary sized pages to be paged out Andrew Morton
2020-10-16  2:42 ` [patch 030/156] fs: add a filesystem flag for THPs Andrew Morton
2020-10-16  2:42 ` [patch 031/156] fs: do not update nr_thps for mappings which support THPs Andrew Morton
2020-10-16  2:42 ` [patch 032/156] mm: fix a race during THP splitting Andrew Morton
2020-10-16  2:42 ` [patch 033/156] mm/readahead: add DEFINE_READAHEAD Andrew Morton
2020-10-16  2:42 ` [patch 034/156] mm/readahead: make page_cache_ra_unbounded take a readahead_control Andrew Morton
2020-10-16  2:43 ` [patch 035/156] mm/readahead: make do_page_cache_ra " Andrew Morton
2020-10-16  2:43 ` [patch 036/156] mm/readahead: make ondemand_readahead " Andrew Morton
2020-10-16  2:43 ` [patch 037/156] mm/readahead: pass readahead_control to force_page_cache_ra Andrew Morton
2020-10-16  2:43 ` [patch 038/156] mm/readahead: add page_cache_sync_ra and page_cache_async_ra Andrew Morton
2020-10-16  2:43 ` [patch 039/156] mm/filemap: fold ra_submit into do_sync_mmap_readahead Andrew Morton
2020-10-16  2:43 ` [patch 040/156] mm/readahead: pass a file_ra_state into force_page_cache_ra Andrew Morton
2020-10-16  2:43 ` [patch 041/156] mm,hwpoison: cleanup unused PageHuge() check Andrew Morton
2020-10-16  2:43 ` [patch 042/156] mm, hwpoison: remove recalculating hpage Andrew Morton
2020-10-16  2:43 ` [patch 043/156] mm,hwpoison-inject: don't pin for hwpoison_filter Andrew Morton
2020-10-16  2:43 ` [patch 044/156] mm,hwpoison: unexport get_hwpoison_page and make it static Andrew Morton
2020-10-16  2:43 ` [patch 045/156] mm,hwpoison: refactor madvise_inject_error Andrew Morton
2020-10-16  2:43 ` [patch 046/156] mm,hwpoison: kill put_hwpoison_page Andrew Morton
2020-10-16  2:43 ` [patch 047/156] mm,hwpoison: unify THP handling for hard and soft offline Andrew Morton
2020-10-16  2:43 ` [patch 048/156] mm,hwpoison: rework soft offline for free pages Andrew Morton
2020-10-16  2:43 ` [patch 049/156] mm,hwpoison: rework soft offline for in-use pages Andrew Morton
2020-10-16  2:44 ` [patch 050/156] mm,hwpoison: refactor soft_offline_huge_page and __soft_offline_page Andrew Morton
2020-10-16  2:44 ` [patch 051/156] mm,hwpoison: return 0 if the page is already poisoned in soft-offline Andrew Morton
2020-10-16  2:44 ` [patch 052/156] mm,hwpoison: introduce MF_MSG_UNSPLIT_THP Andrew Morton
2020-10-16  2:44 ` [patch 053/156] mm,hwpoison: double-check page count in __get_any_page() Andrew Morton
2020-10-16  2:44 ` [patch 054/156] mm,hwpoison: try to narrow window race for free pages Andrew Morton
2020-10-16  2:44 ` [patch 055/156] mm/page_poison.c: replace bool variable with static key Andrew Morton
2020-10-16  2:44 ` Andrew Morton [this message]
2020-10-16  2:44 ` [patch 057/156] mm/util.c: update the kerneldoc for kstrdup_const() Andrew Morton
2020-10-16  2:44 ` [patch 058/156] mm/mmu_notifier: fix mmget() assert in __mmu_interval_notifier_insert Andrew Morton
2020-10-16  2:44 ` [patch 059/156] mm/memory_hotplug: inline __offline_pages() into offline_pages() Andrew Morton
2020-10-16  2:44 ` [patch 060/156] mm/memory_hotplug: enforce section granularity when onlining/offlining Andrew Morton
2020-10-16  2:44 ` [patch 061/156] mm/memory_hotplug: simplify page offlining Andrew Morton
2020-10-16  2:44 ` [patch 062/156] mm/page_alloc: simplify __offline_isolated_pages() Andrew Morton
2020-10-16  2:44 ` [patch 063/156] mm/memory_hotplug: drop nr_isolate_pageblock in offline_pages() Andrew Morton
2020-10-16  2:44 ` [patch 064/156] mm/page_isolation: simplify return value of start_isolate_page_range() Andrew Morton
2020-10-16  2:45 ` [patch 065/156] mm/memory_hotplug: simplify page onlining Andrew Morton
2020-10-16  2:45 ` [patch 066/156] mm/page_alloc: drop stale pageblock comment in memmap_init_zone*() Andrew Morton
2020-10-16  2:45 ` [patch 067/156] mm: pass migratetype into memmap_init_zone() and move_pfn_range_to_zone() Andrew Morton
2020-10-16  2:45 ` [patch 068/156] mm/memory_hotplug: mark pageblocks MIGRATE_ISOLATE while onlining memory Andrew Morton
2020-10-16  2:45 ` [patch 069/156] kernel/resource: make release_mem_region_adjustable() never fail Andrew Morton
2020-10-16  2:45 ` [patch 070/156] kernel/resource: move and rename IORESOURCE_MEM_DRIVER_MANAGED Andrew Morton
2020-10-16  2:45 ` [patch 071/156] mm/memory_hotplug: guard more declarations by CONFIG_MEMORY_HOTPLUG Andrew Morton
2020-10-16  2:45 ` [patch 072/156] mm/memory_hotplug: prepare passing flags to add_memory() and friends Andrew Morton
2020-10-16  2:45 ` [patch 073/156] mm/memory_hotplug: MEMHP_MERGE_RESOURCE to specify merging of System RAM resources Andrew Morton
2020-10-16  2:45 ` [patch 074/156] virtio-mem: try to merge system ram resources Andrew Morton
2020-10-16  2:45 ` [patch 075/156] xen/balloon: " Andrew Morton
2020-10-16  2:46 ` [patch 076/156] hv_balloon: " Andrew Morton
2020-10-16  2:46 ` [patch 077/156] kernel/resource: make iomem_resource implicit in release_mem_region_adjustable() Andrew Morton
2020-10-16  2:46 ` [patch 078/156] mm: don't panic when links can't be created in sysfs Andrew Morton
2020-10-16  2:46 ` [patch 079/156] mm/page_alloc: convert "report" flag of __free_one_page() to a proper flag Andrew Morton
2020-10-16  2:46 ` [patch 080/156] mm/page_alloc: place pages to tail in __putback_isolated_page() Andrew Morton
2020-10-16  2:46 ` [patch 081/156] mm/page_alloc: move pages to tail in move_to_free_list() Andrew Morton
2020-10-16  2:46 ` [patch 082/156] mm/page_alloc: place pages to tail in __free_pages_core() Andrew Morton
2020-10-16  2:46 ` [patch 083/156] mm/memory_hotplug: update comment regarding zone shuffling Andrew Morton
2020-10-16  2:46 ` [patch 084/156] zram: failing to decompress is WARN_ON worthy Andrew Morton
2020-10-16  2:46 ` [patch 085/156] mm/slab.h: remove duplicate include Andrew Morton
2020-10-16  2:46 ` [patch 086/156] mm/page_reporting.c: drop stale list head check in page_reporting_cycle Andrew Morton
2020-10-16  2:46 ` [patch 087/156] mm/highmem.c: clean up endif comments Andrew Morton
2020-10-16  2:46 ` [patch 088/156] mm: use self-explanatory macros rather than "2" Andrew Morton
2020-10-16  2:46 ` [patch 089/156] mm: fix some broken comments Andrew Morton
2020-10-16  2:46 ` [patch 090/156] mm: fix some comments formatting Andrew Morton
2020-10-16  2:47 ` [patch 091/156] mm/workingset.c: fix some doc warnings Andrew Morton
2020-10-16  2:47 ` [patch 092/156] mm: use helper function put_write_access() Andrew Morton
2020-10-16  2:47 ` [patch 093/156] include/linux/mmzone.h: remove unused early_pfn_valid() Andrew Morton
2020-10-16  2:47 ` [patch 094/156] mm: rename page_order() to buddy_order() Andrew Morton
2020-10-16  2:47 ` [patch 095/156] fs: configfs: delete repeated words in comments Andrew Morton
2020-10-16  2:47 ` [patch 096/156] kernel.h: split out min()/max() et al. helpers Andrew Morton
2020-10-16  2:47 ` [patch 097/156] kernel/sys.c: replace do_brk with do_brk_flags in comment of prctl_set_mm_map() Andrew Morton
2020-10-16  2:47 ` [patch 098/156] kernel/: fix repeated words in comments Andrew Morton
2020-10-16  2:47 ` [patch 099/156] kernel: acct.c: fix some kernel-doc nits Andrew Morton
2020-10-16  2:47 ` [patch 100/156] get_maintainer: add test for file in VCS Andrew Morton
2020-10-16  2:47 ` [patch 101/156] get_maintainer: exclude MAINTAINERS file(s) from --git-fallback Andrew Morton
2020-10-16  2:47 ` [patch 102/156] MAINTAINERS: jarkko.sakkinen@linux.intel.com -> jarkko@kernel.org Andrew Morton
2020-10-16  2:47 ` [patch 103/156] lib: bitmap: delete duplicated words Andrew Morton
2020-10-16  2:47 ` [patch 104/156] lib: libcrc32c: " Andrew Morton
2020-10-16  2:47 ` [patch 105/156] lib: decompress_bunzip2: " Andrew Morton
2020-10-16  2:47 ` [patch 106/156] lib: dynamic_queue_limits: delete duplicated words + fix typo Andrew Morton
2020-10-16  2:47 ` [patch 107/156] lib: earlycpio: delete duplicated words Andrew Morton
2020-10-16  2:47 ` [patch 108/156] lib: radix-tree: " Andrew Morton
2020-10-16  2:47 ` [patch 109/156] lib: syscall: " Andrew Morton
2020-10-16  2:48 ` [patch 110/156] lib: test_sysctl: " Andrew Morton
2020-10-16  2:48 ` [patch 111/156] lib/mpi/mpi-bit.c: fix spello of "functions" Andrew Morton
2020-10-16  2:48 ` [patch 112/156] lib/idr.c: document calling context for IDA APIs mustn't use locks Andrew Morton
2020-10-16  2:48 ` [patch 113/156] lib/idr.c: document that ida_simple_{get,remove}() are deprecated Andrew Morton
2020-10-16  2:48 ` [patch 114/156] lib/scatterlist.c: avoid a double memset Andrew Morton
2020-10-16  2:48 ` [patch 115/156] lib/percpu_counter.c: use helper macro abs() Andrew Morton
2020-10-16  2:48 ` [patch 116/156] include/linux/list.h: add a macro to test if entry is pointing to the head Andrew Morton
2020-10-16  2:48 ` [patch 117/156] lib/test_hmm.c: fix an error code in dmirror_allocate_chunk() Andrew Morton
2020-10-16  2:48 ` [patch 118/156] lib/crc32.c: fix trivial typo in preprocessor condition Andrew Morton
2020-10-16  2:48 ` [patch 119/156] bitops: simplify get_count_order_long() Andrew Morton
2020-10-16  2:48 ` [patch 120/156] bitops: use the same mechanism for get_count_order[_long] Andrew Morton
2020-10-16  2:48 ` [patch 121/156] checkpatch: add --kconfig-prefix Andrew Morton
2020-10-16  2:48 ` [patch 122/156] checkpatch: move repeated word test Andrew Morton
2020-10-16  2:48 ` [patch 123/156] checkpatch: add test for comma use that should be semicolon Andrew Morton
2020-10-16  2:48 ` [patch 124/156] const_structs.checkpatch: add phy_ops Andrew Morton
2020-10-16  2:48 ` [patch 125/156] checkpatch: warn if trace_printk and friends are called Andrew Morton
2020-10-16  2:48 ` [patch 126/156] const_structs.checkpatch: add pinctrl_ops and pinmux_ops Andrew Morton
2020-10-16  2:49 ` [patch 127/156] checkpatch: warn on self-assignments Andrew Morton
2020-10-16  2:49 ` [patch 128/156] checkpatch: allow not using -f with files that are in git Andrew Morton
2020-10-16  2:49 ` [patch 129/156] checkpatch: extend author Signed-off-by check for split From: header Andrew Morton
2020-10-16  2:49 ` [patch 130/156] checkpatch: emit a warning on embedded filenames Andrew Morton
2020-10-16  2:49 ` [patch 131/156] checkpatch: fix multi-statement macro checks for while blocks Andrew Morton
2020-10-16  2:49 ` [patch 132/156] checkpatch: fix false positive on empty block comment lines Andrew Morton
2020-10-16  2:49 ` [patch 133/156] checkpatch: add new warnings to author signoff checks Andrew Morton
2020-10-16  2:49 ` [patch 134/156] fs/binfmt_elf: use PT_LOAD p_align values for suitable start address Andrew Morton
2020-10-16  2:49 ` [patch 135/156] tools/testing/selftests: add self-test for verifying load alignment Andrew Morton
2020-10-16  2:49 ` [patch 136/156] binfmt_elf_fdpic: stop using dump_emit() on user pointers on !MMU Andrew Morton
2020-10-16  2:49 ` [patch 137/156] coredump: let dump_emit() bail out on short writes Andrew Morton
2020-10-16  2:49 ` [patch 138/156] coredump: refactor page range dumping into common helper Andrew Morton
2020-10-16  2:49 ` [patch 139/156] coredump: rework elf/elf_fdpic vma_dump_size() " Andrew Morton
2020-10-16  2:49 ` [patch 140/156] binfmt_elf, binfmt_elf_fdpic: use a VMA list snapshot Andrew Morton
2020-10-16  2:49 ` [patch 141/156] mm/gup: take mmap_lock in get_dump_page() Andrew Morton
2020-10-16  2:49 ` [patch 142/156] mm: remove the now-unnecessary mmget_still_valid() hack Andrew Morton
2020-10-16  2:50 ` [patch 143/156] ramfs: fix nommu mmap with gaps in the page cache Andrew Morton
2020-10-16  2:50 ` [patch 144/156] autofs: harden ioctl table Andrew Morton
2020-10-16  2:50 ` [patch 145/156] nilfs2: fix some kernel-doc warnings for nilfs2 Andrew Morton
2020-10-16  2:50 ` [patch 146/156] rapidio: fix error handling path Andrew Morton
2020-10-16  2:50 ` [patch 147/156] rapidio: fix the missed put_device() for rio_mport_add_riodev Andrew Morton
2020-10-16  2:50 ` [patch 148/156] panic: dump registers on panic_on_warn Andrew Morton
2020-10-16  2:50 ` [patch 149/156] kernel/relay.c: drop unneeded initialization Andrew Morton
2020-10-16  2:50 ` [patch 150/156] scripts/gdb/proc: add struct mount & struct super_block addr in lx-mounts command Andrew Morton
2020-10-16  2:50 ` [patch 151/156] scripts/gdb/tasks: add headers and improve spacing format Andrew Morton
2020-10-16  2:50 ` [patch 152/156] sched.h: drop in_ubsan field when UBSAN is in trap mode Andrew Morton
2020-10-16  2:50 ` [patch 153/156] ubsan: introduce CONFIG_UBSAN_LOCAL_BOUNDS for Clang Andrew Morton
2020-10-16  2:50 ` [patch 154/156] ROMFS: support inode blocks calculation Andrew Morton
2020-10-16  2:50 ` [patch 155/156] lib, include/linux: add usercopy failure capability Andrew Morton
2020-10-16  2:50 ` [patch 156/156] lib, uaccess: add failure injection to usercopy functions Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201016024424.biNnIIAcg%akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linmiaohe@huawei.com \
    --cc=linux-mm@kvack.org \
    --cc=mm-commits@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).