All of lore.kernel.org
 help / color / mirror / Atom feed
* [folded-merged] mm-memcg-optimize-user-context-object-stock-access-fix.patch removed from -mm tree
@ 2021-06-29  0:22 akpm
  0 siblings, 0 replies; only message in thread
From: akpm @ 2021-06-29  0:22 UTC (permalink / raw)
  To: hannes, longman, mhocko, mm-commits, songmuchun, vdavydov.dev


The patch titled
     Subject: mm/memcontrol.c: fix potential uninitialized variable warning
has been removed from the -mm tree.  Its filename was
     mm-memcg-optimize-user-context-object-stock-access-fix.patch

This patch was dropped because it was folded into mm-memcg-optimize-user-context-object-stock-access.patch

------------------------------------------------------
From: Waiman Long <longman@redhat.com>
Subject: mm/memcontrol.c: fix potential uninitialized variable warning

If the -Wno-maybe-uninitialized gcc option is not specified, compilation
of memcontrol.c may generate the following warnings:

mm/memcontrol.c: In function `refill_obj_stock':
./arch/x86/include/asm/irqflags.h:127:17: warning: `flags' may be used uninitialized in this function [-Wmaybe-uninitialized]
  return !(flags & X86_EFLAGS_IF);
          ~~~~~~~^~~~~~~~~~~~~~~~
mm/memcontrol.c:3216:16: note: `flags' was declared here
  unsigned long flags;
                ^~~~~
In file included from mm/memcontrol.c:29:
mm/memcontrol.c: In function `uncharge_page':
./include/linux/memcontrol.h:797:2: warning: `objcg' may be used uninitialized in this function [-Wmaybe-uninitialized]
  percpu_ref_put(&objcg->refcnt);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Fix that by properly initializing *pflags in get_obj_stock() and
introducing a use_objcg bool variable in uncharge_page() to avoid
potentially accessing the struct page data twice.

Link: https://lkml.kernel.org/r/20210526193602.8742-1-longman@redhat.com
Signed-off-by: Waiman Long <longman@redhat.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
Cc: Muchun Song <songmuchun@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/memcontrol.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

--- a/mm/memcontrol.c~mm-memcg-optimize-user-context-object-stock-access-fix
+++ a/mm/memcontrol.c
@@ -2115,6 +2115,7 @@ static inline struct obj_stock *get_obj_
 	struct memcg_stock_pcp *stock;
 
 	if (likely(in_task())) {
+		*pflags = 0UL;
 		preempt_disable();
 		stock = this_cpu_ptr(&memcg_stock);
 		return &stock->task_obj;
@@ -6832,6 +6833,7 @@ static void uncharge_page(struct page *p
 	unsigned long nr_pages;
 	struct mem_cgroup *memcg;
 	struct obj_cgroup *objcg;
+	bool use_objcg = PageMemcgKmem(page);
 
 	VM_BUG_ON_PAGE(PageLRU(page), page);
 
@@ -6840,7 +6842,7 @@ static void uncharge_page(struct page *p
 	 * page memcg or objcg at this point, we have fully
 	 * exclusive access to the page.
 	 */
-	if (PageMemcgKmem(page)) {
+	if (use_objcg) {
 		objcg = __page_objcg(page);
 		/*
 		 * This get matches the put at the end of the function and
@@ -6868,7 +6870,7 @@ static void uncharge_page(struct page *p
 
 	nr_pages = compound_nr(page);
 
-	if (PageMemcgKmem(page)) {
+	if (use_objcg) {
 		ug->nr_memory += nr_pages;
 		ug->nr_kmem += nr_pages;
 
_

Patches currently in -mm which might be from longman@redhat.com are

mm-memcg-move-mod_objcg_state-to-memcontrolc.patch
mm-memcg-cache-vmstat-data-in-percpu-memcg_stock_pcp.patch
mm-memcg-improve-refill_obj_stock-performance.patch
mm-memcg-optimize-user-context-object-stock-access.patch
mm-memcg-slab-properly-set-up-gfp-flags-for-objcg-pointer-array.patch
mm-memcg-slab-create-a-new-set-of-kmalloc-cg-n-caches.patch
mm-memcg-slab-create-a-new-set-of-kmalloc-cg-n-caches-v5.patch
mm-memcg-slab-disable-cache-merging-for-kmalloc_normal-caches.patch


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-29  0:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-29  0:22 [folded-merged] mm-memcg-optimize-user-context-object-stock-access-fix.patch removed from -mm tree akpm

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.