Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1021621ybe; Wed, 4 Sep 2019 11:16:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqx21jnpW2jxDlhvlkOgP0v0wGxZaSljcwPYrsms/E4WqWffI1hJkGOUSZ3aXYB9+6jgO+DL X-Received: by 2002:a62:ce0e:: with SMTP id y14mr48022934pfg.73.1567620961767; Wed, 04 Sep 2019 11:16:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567620961; cv=none; d=google.com; s=arc-20160816; b=XtJ7i0kzZa4moYUFfz1efurKsuceUKPFOlsxoxSewj2auYTjZrbz1fOZXZXVYAEr/g i9obzYyVWI7Arv14vabICyVEImenrqyMNrmUektaiVVn+UvbZXkHrxQ0uKmi99g3vdbV mbn9wqDQA5/oJgdVXl4QGG6O8Zl2YI+RuYuWnUX0wX9sa618NHZ7dUpWs5UQFlw0PfYR b9fTfKkblHN6BkNz0zrR+0DrtcIGOp96SyLYvf6T5OUMT8IGCloshivLsEYXQ5SdfsWQ eJKHupPUEbuYCaPQHIxO3xbjzX2qs5Azx6IhkD6OSBXdxjRGnBA3YnfSnm/CfzWcZfvd NW7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7DccEor8KgkF0T61CDpaYjt38YKIw5pwJ8jn4Ve4kws=; b=FklkXHlYcId11OFXFIMnkbscp6mI+pZAmpvRJBq0JEjtplU/M0fDyGjE50Y/NKUnoC z9IPsOEij0NfDn3UcHPQNILzH1JihhSso8v0mMWDIEM4rDXDLxBwwt6Q1+OLQRvaf4/i PMg5NOCC4Fr2/sZcLkFxgnTJ8cUVXV2M3hwx5jk2VWsS9bJ9kgDS1QjKkGZN6NQVYPxQ kwA91EdLYOjs4FDx7CRHIL43U+bsFPy803ydF4FOhPyhx0hm3Ayb/tZiFIaSphig6gcp 30iA892unGXgLPTyf2s1wRKUanMwvDVXiDbJ6iHq9EqlA4iUx9kTEanceNJw45PN02gx SrFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=c8y+nZr+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w1si236677plq.205.2019.09.04.11.15.46; Wed, 04 Sep 2019 11:16:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=c8y+nZr+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390791AbfIDSO0 (ORCPT + 99 others); Wed, 4 Sep 2019 14:14:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:59600 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390485AbfIDSOX (ORCPT ); Wed, 4 Sep 2019 14:14:23 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4761B208E4; Wed, 4 Sep 2019 18:14:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567620862; bh=0yy/2OVnBI5Qh2eAcoybrixJRPrvvYdKrPeHjXlj130=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c8y+nZr+t5o85FOg5ckSs+HQXag2rNIEASH+ZB2j+K5qB6steE8rBcoziV5QTVtPu Zho0/McLaE8UUvZ/Pe/dnLVmhGcfXtvDU6MmwBQFBNpgwmFKEb/QLSchswPzMZzhS/ E7keb+MGUvCGMFAIhC4E6/DIlplVXiqKBJ3tA1tI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shakeel Butt , Roman Gushchin , Michal Hocko , Johannes Weiner , Vladimir Davydov , Andrew Morton , Linus Torvalds Subject: [PATCH 5.2 123/143] mm: memcontrol: fix percpu vmstats and vmevents flush Date: Wed, 4 Sep 2019 19:54:26 +0200 Message-Id: <20190904175319.213100525@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190904175314.206239922@linuxfoundation.org> References: <20190904175314.206239922@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Shakeel Butt commit 6c1c280805ded72eceb2afc1a0d431b256608554 upstream. Instead of using raw_cpu_read() use per_cpu() to read the actual data of the corresponding cpu otherwise we will be reading the data of the current cpu for the number of online CPUs. Link: http://lkml.kernel.org/r/20190829203110.129263-1-shakeelb@google.com Fixes: bb65f89b7d3d ("mm: memcontrol: flush percpu vmevents before releasing memcg") Fixes: c350a99ea2b1 ("mm: memcontrol: flush percpu vmstats before releasing memcg") Signed-off-by: Shakeel Butt Acked-by: Roman Gushchin Acked-by: Michal Hocko Cc: Johannes Weiner Cc: Vladimir Davydov Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/memcontrol.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -3159,7 +3159,7 @@ static void memcg_flush_percpu_vmstats(s for_each_online_cpu(cpu) for (i = 0; i < MEMCG_NR_STAT; i++) - stat[i] += raw_cpu_read(memcg->vmstats_percpu->stat[i]); + stat[i] += per_cpu(memcg->vmstats_percpu->stat[i], cpu); for (mi = memcg; mi; mi = parent_mem_cgroup(mi)) for (i = 0; i < MEMCG_NR_STAT; i++) @@ -3174,8 +3174,8 @@ static void memcg_flush_percpu_vmstats(s for_each_online_cpu(cpu) for (i = 0; i < NR_VM_NODE_STAT_ITEMS; i++) - stat[i] += raw_cpu_read( - pn->lruvec_stat_cpu->count[i]); + stat[i] += per_cpu( + pn->lruvec_stat_cpu->count[i], cpu); for (pi = pn; pi; pi = parent_nodeinfo(pi, node)) for (i = 0; i < NR_VM_NODE_STAT_ITEMS; i++) @@ -3194,8 +3194,8 @@ static void memcg_flush_percpu_vmevents( for_each_online_cpu(cpu) for (i = 0; i < NR_VM_EVENT_ITEMS; i++) - events[i] += raw_cpu_read( - memcg->vmstats_percpu->events[i]); + events[i] += per_cpu(memcg->vmstats_percpu->events[i], + cpu); for (mi = memcg; mi; mi = parent_mem_cgroup(mi)) for (i = 0; i < NR_VM_EVENT_ITEMS; i++)