Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1090170imm; Sat, 14 Jul 2018 22:27:22 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdc+e9n3whDDVE4AlT4XoK5sN9X9cIwESehm7bOH1l/dsQXEzJ9EaW4RP7Rbx4ZNovk6ULR X-Received: by 2002:a62:d24a:: with SMTP id c71-v6mr13280659pfg.242.1531632442115; Sat, 14 Jul 2018 22:27:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531632442; cv=none; d=google.com; s=arc-20160816; b=0V7bP/8RqzppMTSXTobPRO+dD0Hr8k1kLnSEgCPvvAIM4Fv7N1Zk6xJzs32piik64w b6+gkB0PUfOej+4mHUgvEDO67dPE1J7wC/A871vv0StCY2qkhWBip4TtUH4esTKEJ+zk qqbR1i/p5v+nn2QpM2VemsEKaH5lvLiErrsg7XqWlmRoxFCcd6R5swjTBqrqxCtSGxRG SWMvhr9OpZ3OaPfShdTFAfRFSl/XgWbws5zhUnEXMOnaD15hEF7bPJb6xDe3Ab6tKdjj FrESNsnMhb/K9mzcD9UHqf6GeN0wtdl9wbHK9lPjJp2Sgc3JfUghvB3IJpd4GWjuYhRM aPbQ== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=QW17LzTKLHMlIiGKf4STqLTs13MMTL942LYGFPuVZMs=; b=ADofoDFGh4Vx6r2kSXyOnv4X55Mb+r1od4D74AZVVkTvILP5D/mynDa9ONfkWVDjNN Gr36Vz1HPaoEOEXJKQI5aidUaSB7MeoF5upiIKD5R/igdfUlwx74YvhN7Z+PBuiK+WHe yooKtGIXn8CuhZfzrLUCgOe2c5QdudxJ3nHG3ol7G5R800QAfsiHuqLPjXz+AtLv6xA0 HlrjCkpIJS6Gu3PC4tLb0R6AF7k7niovAPekxuQvDEt4rICPS66p9jdoYXm005FYpWBn DE1ymDdeA0/TJWevFCNI2rwvtka1aAF8yOx0HPxU+gT79PctSMtDVL+LRBnKNsC2kWOP st4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gsfuxnNZ; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p129-v6si29075099pfb.145.2018.07.14.22.26.57; Sat, 14 Jul 2018 22:27:22 -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=@gmail.com header.s=20161025 header.b=gsfuxnNZ; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726229AbeGOFrp (ORCPT + 99 others); Sun, 15 Jul 2018 01:47:45 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:46444 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726010AbeGOFrp (ORCPT ); Sun, 15 Jul 2018 01:47:45 -0400 Received: by mail-io0-f195.google.com with SMTP id i18-v6so19058391ioj.13; Sat, 14 Jul 2018 22:26:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=QW17LzTKLHMlIiGKf4STqLTs13MMTL942LYGFPuVZMs=; b=gsfuxnNZDAHzAckT+84CKifnK1H6CjeiwwVqmDCh4AEcJxLtb+NKczlxkm6bB/enwe UQYgimzDW4iol9c2ZJ/MQQSuByGTW4xEGfe2fg/767BVzLcJqErlDIDJwsBNHqloCvhL ZzUStoMcCOhVTHIsxDFLO+tWqztC/tpkZq/zy6XoogUapdWEm8a8hmQ5e0opbKMWM/4c e+cQ8c3cdY1uQOkMTV0VUhpTiMJLZoSGfag0+8GZep3Q78x45rD5AjHL+EJLgZ8ss9E9 sQgGNR+07oHVddAoCUXr8tp0fdI5MJ09khQguO/8Z8ItYMc0C1uFez2aMVmqStkdpJJd DmtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=QW17LzTKLHMlIiGKf4STqLTs13MMTL942LYGFPuVZMs=; b=ckofZw61MY6LK0QaWilQSD7RJOpQJ0Z/bAHxrWOfcUesTfmkUo3r3gTW99FdVyFToK P9tksXhbncv8+8hBACj8bzH+Jwr2FUcUMfZm4uwhrQzhhhQOGOM2F6Ac4MCKUi6jb5Xy OTZhXmoOPRiA1fwCTFoxuA8wj+DxNCph5h0OeL8cxelREPvmhtPelmNtZBmLVQjiW05g j+yIItKs1l5PJFgWtae0BHPZGlm4j4rOB+5FjHEXxGOCW+FAgdKdBNf2+8k+iluXlyzX rLw8+5WK/aNbWVnfkp9mDOPuNw6OsC1HjbhiPBgS17P5dxdQqn0piwbIglIQ3WcJKKcf B/bA== X-Gm-Message-State: AOUpUlHpWAxvp1wJ46REpMBxonfRdexcUVU05s2CTOC0qaGzWAF014p5 fkn30xGnQAjEQgzd+owqixnCC7GquS2n/CwUmJo= X-Received: by 2002:a6b:b845:: with SMTP id i66-v6mr33801372iof.142.1531632366361; Sat, 14 Jul 2018 22:26:06 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:7a47:0:0:0:0:0 with HTTP; Sat, 14 Jul 2018 22:25:25 -0700 (PDT) In-Reply-To: References: <1531557122-12540-1-git-send-email-laoar.shao@gmail.com> From: Yafang Shao Date: Sun, 15 Jul 2018 13:25:25 +0800 Message-ID: Subject: Re: [PATCH] mm: avoid bothering interrupted task when charge memcg in softirq To: Shakeel Butt 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 Sun, Jul 15, 2018 at 12:25 PM, Shakeel Butt wrote: > 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. > That's correct, the memcg if from the sock object. But the point is, in this situation why 'current' is used in try_charge() ? As 'current' is not related with the memcg, which is just a interrupted task. > If the network buffers is allocated through kmem interface, the > charging is bypassed altogether (through memcg_kmem_bypass()) for > interrupt context. > Yes. Thanks Yafang