From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A4C4C433E0 for ; Fri, 15 May 2020 08:35:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 53DC9206F4 for ; Fri, 15 May 2020 08:35:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 53DC9206F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DB4E790000C; Fri, 15 May 2020 04:35:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D664C8E0005; Fri, 15 May 2020 04:35:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C544990000C; Fri, 15 May 2020 04:35:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0208.hostedemail.com [216.40.44.208]) by kanga.kvack.org (Postfix) with ESMTP id AA0E68E0005 for ; Fri, 15 May 2020 04:35:02 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 5DC868248047 for ; Fri, 15 May 2020 08:35:02 +0000 (UTC) X-FDA: 76818293244.02.north51_662b5d0776626 X-HE-Tag: north51_662b5d0776626 X-Filterd-Recvd-Size: 4451 Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Fri, 15 May 2020 08:35:01 +0000 (UTC) Received: by mail-wm1-f68.google.com with SMTP id u16so1664468wmc.5 for ; Fri, 15 May 2020 01:35:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=VmR2sJIk1w11Ugn/97XQiLnKGg9jqySC52XUmtX4lqo=; b=nGjjo8K1wRPVbP6Zpb4rwCwZ1rPSHqCCvGtVZ3QS8qt/NDcXYHqTNPycKnmi/K8wYP qibKw2E5B3DMg5Mkt1mNiiFyT5/KbUgw3SuLmJ9o1Tz7z1qwqc6NKs20ZeRWEqhg9hei pXDLjTfrXI07seGgGtmWOp9LT0QSnTSseqCBQtny5iam1jrHR+1zZEF/k1tFhDVQDcVJ UQnzHnMdfGFIumEf5KKG68IulcJ2ZWc1iBUzh5J+GMpcOAeN/z96cibH2dcmrBXzJmdH 1SsichLjHSEsvFQfrEQiNF71beZa00dQLRUg35xXuuhFv22k9RFFpGDP4ZluU46Sq0R6 mfrw== X-Gm-Message-State: AOAM532Zs5IkpJiGoBMCULZNfHOZI7gLIcqEsc5eK6i0quEg5hBy+AD8 C6ln1xEr+BX+kHgLiJnlu8k= X-Google-Smtp-Source: ABdhPJw9r3i0QDrfKP6xdLPLkp+JSugGzjFMzfPjTnW1sUly98WrdQXcjqitHPNoIICvc3kJJUoD1w== X-Received: by 2002:a1c:720d:: with SMTP id n13mr2776680wmc.130.1589531701058; Fri, 15 May 2020 01:35:01 -0700 (PDT) Received: from localhost (ip-37-188-249-36.eurotel.cz. [37.188.249.36]) by smtp.gmail.com with ESMTPSA id b18sm2411606wrn.82.2020.05.15.01.34.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 01:35:00 -0700 (PDT) Date: Fri, 15 May 2020 10:34:58 +0200 From: Michal Hocko To: Zefan Li Cc: Roman Gushchin , Johannes Weiner , Vladimir Davydov , Cgroups , linux-mm@kvack.org, Andrew Morton , Shakeel Butt Subject: Re: [PATCH v2] memcg: Fix memcg_kmem_bypass() for remote memcg charging Message-ID: <20200515083458.GK29153@dhcp22.suse.cz> References: <20200513090502.GV29153@dhcp22.suse.cz> <76f71776-d049-7407-8574-86b6e9d80704@huawei.com> <20200513112905.GX29153@dhcp22.suse.cz> <3a721f62-5a66-8bc5-247b-5c8b7c51c555@huawei.com> <20200513161110.GA70427@carbon.DHCP.thefacebook.com> <20e89344-cf00-8b0c-64c3-0ac7efd601e6@huawei.com> <20200514225259.GA81563@carbon.dhcp.thefacebook.com> <20200515065645.GD29153@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri 15-05-20 16:20:04, Li Zefan wrote: > On 2020/5/15 14:56, Michal Hocko wrote: > > On Thu 14-05-20 15:52:59, Roman Gushchin wrote: [...] > >>> I thought the user should ensure not do this, but now I think it makes sense to just bypass > >>> the interrupt case. > >> > >> I think now it's mostly a legacy of the opt-out kernel memory accounting. > >> Actually we can relax this requirement by forcibly overcommit the memory cgroup > >> if the allocation is happening from the irq context, and punish it afterwards. > >> Idk how much we wanna this, hopefully nobody is allocating large non-temporarily > >> objects from an irq. > > > > I do not think we want to pretend that remote charging from the IRQ > > context is supported. Why don't we simply WARN_ON(in_interrupt()) there? > > > > How about: > > static inline bool memcg_kmem_bypass(void) > { > if (in_interrupt()) { > WARN_ON(current->active_memcg); > return true; > } Why not simply if (WARN_ON_ONCE(in_interrupt()) return true; the idea is that we want to catch any __GFP_ACCOUNT user from IRQ context because this just doesn't work and we do not plan to support it for now and foreseeable future. If this is reduced only to active_memcg then we are only getting a partial picture. > > /* Allow remote memcg charging in kthread contexts. */ > if ((!current->mm || (current->flags & PF_KTHREAD)) && !current->active_memcg) > return true; > return false; > } -- Michal Hocko SUSE Labs