Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1059309imm; Sat, 14 Jul 2018 21:28:15 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcNCMwpNfncZSFFXQf+13IcIDd+zvH8KNqjFnFiPv6TZVN4ANh/WLDWjhOJexyYPCGS1yXT X-Received: by 2002:a62:d10b:: with SMTP id z11-v6mr13195838pfg.255.1531628895424; Sat, 14 Jul 2018 21:28:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531628895; cv=none; d=google.com; s=arc-20160816; b=vYzXsnLn1yarqT4iB0QgOjMctmmuBU9Cqyx2n8BegqYU1qOq0xKjq4ME0pemZR5rYK qnRPyYNFBa2l9+3LZQuATfHyOk3xngLqTao1nscA4ltInWhoEaiuYSuB0H9tw67fXMyK HlUY5KIXCKW5D69Eza0t0N0ET4tTbGaYxdNnkzngzR9VzCYTis3kDjtTbG2CB7PNuvSm YcKiNDRHnZuA7TF4VIzFtSzj7NUK3HLQGxl8rYqV4piK1BVrKowK9S+nsK/1He9s3MEi v70FH6DuDLNkbfEf7vCLIBzEliAqq4gmgDeCYRB+HwsY3g9kIPTgKnF4TyUCGqB+YQKF 0ekA== 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 :arc-authentication-results; bh=4OObvl9YHFDf56+yHYi/GcQGih1Kzx7x91kF95IH8A0=; b=CLMhpEmmnXH8vhGo1ZNNBUFo8Xz4ZED2aGpDmFZHJgs4YvfGlaHdw7tMKDEzFSa4R+ i9ANQVR6gz81X7xnsBd8/PvcseO3l93tGJ5oYhi3AuBPXvdG3Hvv5F0G4e5Hhp01fiFb w2AXohmTtPyo3vnEeyRpaFAoNMZiXYMsjwFlE9XcJwCOwDL7hZ8kufQMfj2HnKlEpUa6 QEI2oE+8fLBQmpSFJc6c1Nw+Eo5anP0/Q/pW9+PbLPjKdN/iZ9zcWeRWQ2Z0Zs/hd+th z1HspLrBoJZc9PZZiTvjPHYGi7lc3iO0P7oFczVuhdQ6Qu1tzbRGcdazZoDnF5fTisUn pNwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=UNt8tGLk; 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 a16-v6si14565719pgw.389.2018.07.14.21.27.49; Sat, 14 Jul 2018 21:28:15 -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=@google.com header.s=20161025 header.b=UNt8tGLk; 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 S1726069AbeGOErQ (ORCPT + 99 others); Sun, 15 Jul 2018 00:47:16 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:39056 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725745AbeGOErP (ORCPT ); Sun, 15 Jul 2018 00:47:15 -0400 Received: by mail-wm0-f68.google.com with SMTP id h20-v6so12565644wmb.4 for ; Sat, 14 Jul 2018 21:25:45 -0700 (PDT) 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=4OObvl9YHFDf56+yHYi/GcQGih1Kzx7x91kF95IH8A0=; b=UNt8tGLk4+riZ4+ns8OFQBi64HlSLpUUjRI51/NFgYHlU+LDG4krU+60tO1pQ+0j4w dg64ARhT24KnGq5jyygT0v4/rugg1LjyNkQbbVUSBBQdZnsvh6g01s7Gfr0KTjlV67RY AN0PmwEtP762CPFuVpO00AVLrEb2KrUXsfVpbGPAVI4ElMj4val5FXAYOUF2mmKQh6di /dE6P0OlXah4NbG84KhpreOgfmt7VZ+Xcsdak84SkGSUPjkBI3rJ+Rxs/d9NK7ysjvNT xTDOp2F3gdizwR4x8xiYDb/heTR1p/mlDpw3Hmbm1+tBnTIa8s4kpUIjA8XCUBIQki2I IskA== 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=4OObvl9YHFDf56+yHYi/GcQGih1Kzx7x91kF95IH8A0=; b=fSZrPeMEVzedV/I1/gJsIIxqU92P8NnnHEQI/A7ARm6dBA4KYYtpu6p22+KAU4PJWJ j6xxK8qT0l2wSQXX9IJ9E5nTGCIxEHTeYcebT9ND1rIGGCrfcAWPNOR4D53fke4tZHf5 b6Nll9rgilogEQ7xWcGDCfsXZppQCC6FGHb0PX+8XBhqLx7xV1Oln5JtYVNbfmOr2ATB AQGbbUPyWVD69E/2dnWP0hPOTIlufm625JFLvO8c8KYD2M6ZooueVfvO5TElSGyjz8S3 FlpQO4OJVfnA+7m/nHxT0Ex4zz9W2HEbbnRp2Kr/poORSn75lp39o27hRQmZbP8CP/BQ F1oQ== X-Gm-Message-State: AOUpUlFoVwnaTSMm2fyzkG2SqaDjyOp0dSDqcfcdJGsklHkqQuq2xAHI Ul/92/f9NG1XXARAocDSeyPQ9wHWEjyEDF6eQqLSqQ== X-Received: by 2002:a1c:63d4:: with SMTP id x203-v6mr6839811wmb.9.1531628744144; Sat, 14 Jul 2018 21:25:44 -0700 (PDT) MIME-Version: 1.0 References: <1531557122-12540-1-git-send-email-laoar.shao@gmail.com> In-Reply-To: From: Shakeel Butt Date: Sat, 14 Jul 2018 21:25:31 -0700 Message-ID: Subject: Re: [PATCH] mm: avoid bothering interrupted task when charge memcg in softirq To: Yafang Shao Cc: Johannes Weiner , Michal Hocko , Vladimir Davydov , Cgroups , Linux MM , 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 Sat, Jul 14, 2018 at 7:10 PM Yafang Shao wrote: > > On Sat, Jul 14, 2018 at 11:38 PM, Shakeel Butt wrote: > > On Sat, Jul 14, 2018 at 1:32 AM Yafang Shao wrote: > >> > >> try_charge maybe executed in packet receive path, which is in interrupt > >> context. > >> In this situation, the 'current' is the interrupted task, which may has > >> no relation to the rx softirq, So it is nonsense to use 'current'. > >> > > > > Have you actually seen this occurring? > > Hi Shakeel, > > I'm trying to produce this issue, but haven't find it occur yet. > > > I am not very familiar with the > > network code but I can think of two ways try_charge() can be called > > from network code. Either through kmem charging or through > > mem_cgroup_charge_skmem() and both locations correctly handle > > interrupt context. > > > > Why do you say that mem_cgroup_charge_skmem() correctly hanle > interrupt context ? > > Let me show you why mem_cgroup_charge_skmem isn't hanling interrupt > context correctly. > > mem_cgroup_charge_skmem() is calling try_charge() twice. > The first one is with GFP_NOWAIT as the gfp_mask, and the second one > is with (GFP_NOWAIT | __GFP_NOFAIL) as the gfp_mask. > > If page_counter_try_charge() failes at the first time, -ENOMEM is returned. > Then mem_cgroup_charge_skmem() will call try_charge() once more with > __GFP_NOFAIL set, and this time if If page_counter_try_charge() failes > again the ' > force' label in try_charge() will be executed and 0 is returned. > > No matter what, the 'current' will be used and touched, that is > meaning mem_cgroup_charge_skmem() isn't hanling the interrupt context > correctly. > Hi Yafang, If you check mem_cgroup_charge_skmem(), the memcg passed is not 'current' but is from the sock object i.e. sk->sk_memcg for which the network buffer is allocated for. If the network buffers is allocated through kmem interface, the charging is bypassed altogether (through memcg_kmem_bypass()) for interrupt context. regards, Shakeel