Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp185715ybf; Wed, 26 Feb 2020 11:08:28 -0800 (PST) X-Google-Smtp-Source: APXvYqzPdZFeF5QtkqU/2B2AH2wND/4v8NenF7Bgv7Bh+Cfu6/r4CA4EmjPsvrGr5tPS/ZozI8zA X-Received: by 2002:a05:6830:1db3:: with SMTP id z19mr221872oti.292.1582744108028; Wed, 26 Feb 2020 11:08:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582744108; cv=none; d=google.com; s=arc-20160816; b=a6/8vgI1xonve1TFphsJQcYSGznK9OtIUp1GmvKpSEg2kgdejLB8FBUf5TtDBgS/Ep PLYRpqCO+sk5tvn2eZlF9yvoS9wvKeajfsHgKlTlDMLJz/UBAKYw3nWsGEfAPxPSlqIv qsbvsY+WHQY4CClYgT+K8K0f1sHS6FR9XahnFJ4YwApGyQ6BFBolu0KwTmgGWPS6fIqS XNbliJS7KfoLhd96pp2yfJRS8NHieRltnJ11AWLxm9hoKTnuj9vNxx5m5bZTWMdboaL1 ZvwKAHcM1oyJKElRPFlOG+vnp2axEAXZd89XymcB2fSr6yHdWolXtdVmbZ2RtEg1n4zs b5fA== 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 :references:in-reply-to:from:subject:cc:to:message-id:date; bh=MaVqUOrb2IU/zFamsrPQ3RHvteECZLAEFFDixPUdm8g=; b=Go0lxhsl5v09v6b+lA3hpRy2UUHBW3zEwkzEsuJKmg210XO1i1F+yy3+vxUd/mrPXq 9fAESmZccSsNzZRINnx/ev8epVjE+AqIhbmqf43yjg1t/IeXl0b7KdAFOA8el55RNnDh 0KMn5hh3JySoki8JXdbUkNyVzzqYntDdbxszTeeQKrAOeHznGlZjpZvQcuugq1+e+DxU ebDOfXuZyZBGerlIbV/I0G9ses4PkRiDBzpt7dDwnMHaEor4gAqftU9DREuEPGx0v/pC e15Nw8Ck6xrPWdhOUOBGruHPAydTfzGG0Anm5Y+nfxx6b6baYC3EU4VFDo1I7Cn2bpjk 2eHw== ARC-Authentication-Results: i=1; mx.google.com; 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 z18si229331otq.121.2020.02.26.11.08.15; Wed, 26 Feb 2020 11:08:27 -0800 (PST) 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; 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 S1727225AbgBZTHz (ORCPT + 99 others); Wed, 26 Feb 2020 14:07:55 -0500 Received: from shards.monkeyblade.net ([23.128.96.9]:60140 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727035AbgBZTHz (ORCPT ); Wed, 26 Feb 2020 14:07:55 -0500 Received: from localhost (unknown [IPv6:2601:601:9f00:477::3d5]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id 5044515AA1098; Wed, 26 Feb 2020 11:07:52 -0800 (PST) Date: Wed, 26 Feb 2020 11:07:49 -0800 (PST) Message-Id: <20200226.110749.77396284962321904.davem@davemloft.net> To: shakeelb@google.com Cc: edumazet@google.com, guro@fb.com, hannes@cmpxchg.org, tj@kernel.org, gthelen@google.com, mhocko@kernel.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH v3] cgroup: memcg: net: do not associate sock with unrelated cgroup From: David Miller In-Reply-To: <20200221014604.126118-1-shakeelb@google.com> References: <20200221014604.126118-1-shakeelb@google.com> X-Mailer: Mew version 6.8 on Emacs 26.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Wed, 26 Feb 2020 11:07:52 -0800 (PST) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Shakeel Butt Date: Thu, 20 Feb 2020 17:46:04 -0800 > We are testing network memory accounting in our setup and noticed > inconsistent network memory usage and often unrelated cgroups network > usage correlates with testing workload. On further inspection, it > seems like mem_cgroup_sk_alloc() and cgroup_sk_alloc() are broken in > IRQ context specially for cgroup v1. > > mem_cgroup_sk_alloc() and cgroup_sk_alloc() can be called in IRQ context > and kind of assumes that this can only happen from sk_clone_lock() > and the source sock object has already associated cgroup. However in > cgroup v1, where network memory accounting is opt-in, the source sock > can be unassociated with any cgroup and the new cloned sock can get > associated with unrelated interrupted cgroup. > > Cgroup v2 can also suffer if the source sock object was created by > process in the root cgroup or if sk_alloc() is called in IRQ context. > The fix is to just do nothing in interrupt. > > WARNING: Please note that about half of the TCP sockets are allocated > from the IRQ context, so, memory used by such sockets will not be > accouted by the memcg. Then if we do this then we have to have some kind of subsequent change to attach these sockets to the correct cgroup, right?