Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp995459imm; Sat, 14 Jul 2018 19:11:41 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcbSNZnhf6dWuRGSboO6EgkNfosWWbbbyq/i8RpWlOOiBQECNhLUfCSe72lRMKgaiaz9JPh X-Received: by 2002:a17:902:a40b:: with SMTP id p11-v6mr11857837plq.228.1531620701884; Sat, 14 Jul 2018 19:11:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531620701; cv=none; d=google.com; s=arc-20160816; b=k6RjYPhJjYpdxPZxwSWMXYTuPioNT1LDahHx7uCPTnbFKpltWPlSbuve3xjgAOAI+y zx97TC4GpPWR7L7WaYYrgQ1Sj/uEkkl3AwshwvGXdoXd3fRWDteDHvNareHc1O1iJKv2 ywlMgXEyxfXRfngFWQds0WCeDtLSNYcSnuO+AUJfbaWRmW4Nq96HRSETAD5NMn0moE6J t7FhESRBVdKux24l+pbk4/IfjiZ1me5jjV1nTlxTNu1yuvtd3x0TvMCtTBln5gdRL9Tb rLm3GOwNFb2mCAF1fSdLaztPCHVS6CufFHsxkOA7/Uhbn2Z0zMp7xnOpe+Ho3qpqTjkv Vu8A== 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=kqJSv2Ubljjt/IjTKrl1FAo40tWJZsUFjKXl1ffUHqA=; b=h20iixIlx3u7JK3SKOT3NIbSfv+aPfcFcrpXhZy7m8mNYFItHroHLJ5wnZHBYhMz0H 1CiQTlt571M7AA58hIUUqyT+BaNovU63Oti6ZZYVdBd7du/zcNpv26fGMQMPiApih1cs PHI4D1HoHRCehu1LN2Q7CcFik7Vk8CSQw8TTcKWtKhGGb1mY1Sxfc7B5G/OZeSIFbWhw E1saP49qpeC6yzN3BYxzw8BiYBWq0m4z/lzmAGJGh3H9S8mUPNvR5lKsrl9lCQepPEAU MeOBFzRF6ObShBk33Z5Hu8PGS6UntssS3DUJlGpYAH/6HjvrmAMQ6EhxB4/7nZOr7zrd Oivg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XPzgGwem; 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 97-v6si12166378ple.113.2018.07.14.19.11.25; Sat, 14 Jul 2018 19:11:41 -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=XPzgGwem; 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 S1732589AbeGOCb7 (ORCPT + 99 others); Sat, 14 Jul 2018 22:31:59 -0400 Received: from mail-it0-f65.google.com ([209.85.214.65]:55664 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731950AbeGOCb7 (ORCPT ); Sat, 14 Jul 2018 22:31:59 -0400 Received: by mail-it0-f65.google.com with SMTP id 16-v6so16297567itl.5; Sat, 14 Jul 2018 19:10:50 -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=kqJSv2Ubljjt/IjTKrl1FAo40tWJZsUFjKXl1ffUHqA=; b=XPzgGwem3J1j0z49Ln85QCWkZl6/MRuHIe4Ep2JbH5r5bBDuHy4mvGwcQqOtvUgVox yDxgtLUICSGdPZ8Lcy9DGeurC7cn6s2p5ndbDZWdF4Hy6310dd1edj8GPgrsuc+Agxvu 65QIYT/9oZCw5JkjulBgJYvdbnytcv5wInB73ATfVHxdU/fQzvSo8YwapGkElGY26SJL sUoRc3C3uJNd9y7zDAXNINW3GIfrLOo+rhtpZpUX/83fS54ZhUdtVsBL24kyVbbrdN+f upIwKKZCwswbPXboZbdRVC1iEIh2CxOhwJi+n37gpn/uH8nU6iqHEpxGxzL6EfOunbbM dP0g== 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=kqJSv2Ubljjt/IjTKrl1FAo40tWJZsUFjKXl1ffUHqA=; b=IfZdv7YDBuXrwQZizahWLhVL20BRNfgNfOUOr4WiN6x/BbworLOouQT6GcmhmPE4GR mFMd6t+br//mZwgOg6UYAYsVONCO7aVU+oknP8KQ3wzHqgwCL1/ehOZWg7HYxPmPfL8f 0iZv54EBMs7t4dAEj37yTL9rMU5jQmu3Z85gPEJwTxoYZnd7rtxLEH6Ic70Aafb1LhmS fy1e3zVWm3U1eHse/uUIeI3vbjTcwJTkKHVcppRTt7d25i4inadyUOTJtjQc4as+cjnY J4oQvI2NMeY20DwoXKV/6vMeE6DzvqN9jnq53bnGYyVnHWpnK7hFcXfQ6DfX+71VV9N8 MIHA== X-Gm-Message-State: AOUpUlEuWracABVLJROCrt0o3dQRfhVJO6WQ037EIxQiAZTS8920gM+O IfqManxnfU6fm6zj6G3wRNHZrw203lDs+zaC5hI= X-Received: by 2002:a24:5004:: with SMTP id m4-v6mr8854447itb.38.1531620650437; Sat, 14 Jul 2018 19:10:50 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:7a47:0:0:0:0:0 with HTTP; Sat, 14 Jul 2018 19:10:10 -0700 (PDT) In-Reply-To: References: <1531557122-12540-1-git-send-email-laoar.shao@gmail.com> From: Yafang Shao Date: Sun, 15 Jul 2018 10:10:10 +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 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. Pls. let me know if I miss something. Thanks Yafang