Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2315934ybv; Fri, 14 Feb 2020 16:13:25 -0800 (PST) X-Google-Smtp-Source: APXvYqw6eXLNI1Gb701Z+99yhUwAa9dDZwjK/GTXU3YWONxnQ++LH1Om/sWHw1cpd3ke2k3hCOSK X-Received: by 2002:a05:6830:1e6b:: with SMTP id m11mr4397555otr.293.1581725604984; Fri, 14 Feb 2020 16:13:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581725604; cv=none; d=google.com; s=arc-20160816; b=Na+XtCE0hxAUKPw8b+G2fkt0i+nd2PwcH14AIIIi5TldFVSrrX6J9CcJVx+bWj2ewr Uxjs9SqwFJyjRtx84cKo0R9IGkaOrM4dyeUhmEkmCNmDn1lTVk7CcE72gKZq7bHuIhKX /+RzgJeTa50ilGY34GeU/j/zL78+vXukXpF2ZzLMeAaok79naMKaXfqn+ZiN0Kqth2X5 Zjh0gMiXe7F7hHoPybk6EeQ5AjGSqx5a7Dzyf2YmWLA8GnI4RQBbAxokG/ijnN6ajMJO /O0ouW/bQBo70h61SXRImZSq50nUpeY21c4pX0ZCskaO8MiL9slUrC+gz8LZGCFepJCI 2sgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Qj2zBbkIxBGfCERuHV86VP5E7OnuA4mxy13S+8Juj1A=; b=JL+Y40Y537CoRFD+7KGA+XzO8UGJtbbvR6Iny9EzqoP0oYJCgK9xTw4W8vkYCH6dvz mYxRSaPU2UjrQ8asXXChs8xofhFxDHJbPBb68PxdIX3TA+DgYmXPEwJU/wz1WhGu+xoc Kfxa26e5Z2b5+1vPCxPz7UoKd9GnLoiQ0gJjXbV5wwyzrhibczCVQTnXW81z5pa3W3A4 vLb+rbavPVqBKBPfaBlrwtssz6ZMQJl258iyFF/qODpJgExQWT53ALaOdn1pWT4XvO39 8mmaEdplC0Ar+T7B/D+FDHtffeh5TZY0/AIa5ZRcOFKEOhyHu2ayOOVrg5EWntg4KUND TKtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=mQXv020x; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w13si3463898oiw.106.2020.02.14.16.13.10; Fri, 14 Feb 2020 16:13:24 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=mQXv020x; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727772AbgBOALi (ORCPT + 99 others); Fri, 14 Feb 2020 19:11:38 -0500 Received: from mail-yb1-f194.google.com ([209.85.219.194]:44709 "EHLO mail-yb1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727684AbgBOALh (ORCPT ); Fri, 14 Feb 2020 19:11:37 -0500 Received: by mail-yb1-f194.google.com with SMTP id f21so5656038ybg.11 for ; Fri, 14 Feb 2020 16:11:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Qj2zBbkIxBGfCERuHV86VP5E7OnuA4mxy13S+8Juj1A=; b=mQXv020xrGiFQVRcG+t3iVDyjz5L4TGdw0U6fbXeCwxrDC4hDSpg0HBUuUifRpC35r IAr+R+LZdTurVkQIlblgBmObc9b8hX5L2QMJXSgw+ykNNQcG5LVdhpwoKmSquITh5FDc me1wYFI8+0AcXmPj9ameun83h8tbAFaCzlBQVnK9wL0CfDhdWHFsRLu+6RaIUliQg3mx FEvcu8Ar1zcLaMHBuLvh3rsYsOfl0C2RlyfjNt65BG+ROrPNebXJjL0UYf9LxR0gYO5q 4Entvu6OAzKq+H8KYWL1LRp/fdJbWViG6JTmq3xbcl9LNkt596K8wSd8/aHFGmc4lO1e VG0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Qj2zBbkIxBGfCERuHV86VP5E7OnuA4mxy13S+8Juj1A=; b=n1GVeyTBRadKXh2/8rRgp1Y3uWzWiBC96WyBAJMa5mZZNmhC8VpIwrPiRIJFtZwWBb uEOp1YJHsahGHFu7afllTGobnTCvg6Ifz+P9Xip7bCQ8B8raWfKx3VR+tB8d+YLoHEsv jLhofQmxjGmCKSA5SBbhMaCqAB0ODq1S5GtRJZ5ZsCH7UQd15DuiYzlOy+6gOSKXrwX8 EOIE8LOdjG/GPDf39FPCe1sDhmdzMDGMV+kVjwTxwGeHt5fgb23gynONF8UgLnrTQvf7 toanAkw7SXwFPYNYfIIFGfBpxbvUNDauG1/gI5jv+GP44iC8h5DtYNin1bV8O2Ljw0Zb gqQg== X-Gm-Message-State: APjAAAUrS0TNvALHDNOj0C4Oq5hPWaFCXJbAifFYj49QaaMpCkySW6/I fdPIcj2RDZrjIBGL6Y/4tSo2Tm2jx3VFDPngw2cCBA== X-Received: by 2002:a25:b949:: with SMTP id s9mr5305834ybm.274.1581725496112; Fri, 14 Feb 2020 16:11:36 -0800 (PST) MIME-Version: 1.0 References: <20200214222415.181467-1-shakeelb@google.com> In-Reply-To: From: Eric Dumazet Date: Fri, 14 Feb 2020 16:11:24 -0800 Message-ID: Subject: Re: [PATCH v2] cgroup: memcg: net: do not associate sock with unrelated cgroup To: Shakeel Butt Cc: Johannes Weiner , Tejun Heo , Greg Thelen , Michal Hocko , Vladimir Davydov , Andrew Morton , Cgroups , linux-mm , Roman Gushchin , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 14, 2020 at 4:04 PM Shakeel Butt wrote: > > On Fri, Feb 14, 2020 at 3:12 PM Eric Dumazet wrote: > > > > On Fri, Feb 14, 2020 at 2:48 PM Shakeel Butt wrote: > > > > > > > > I think in the current code if the association is skipped at > > > allocation time then the sock will remain unassociated for its > > > lifetime. > > > > > > Maybe we can add the association in the later stages but it seems like > > > it is not a simple task i.e. edbe69ef2c90f ("Revert "defer call to > > > mem_cgroup_sk_alloc()""). > > > > Half TCP sockets are passive, so this means that 50% of TCP sockets > > won't be charged. > > (the socket cloning always happens from BH context) > > > > I think this deserves a comment in the changelog or documentation, > > otherwise some people might think > > using memcg will make them safe. > > Thanks I will update the changelog. Also is inet_csk_accept() the > right place for delayed cgroup/memcg binding (if we decide to do > that). I am wondering if we can force charge the memcg during late > binding to cater the issue fixed in edbe69ef2c90f. > Yes, this is exactly why accept() would be the natural choice. You do not want to test/change the binding at sendmsg()/recvmsg() time, right ?