Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1066112imm; Fri, 29 Jun 2018 10:46:49 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJTlspNavZadrqIhafA3NKZv8fkpz1SIUzwK1pfngJteCN68iHW+fW5OWmYoCBfNIkpgjN/ X-Received: by 2002:a17:902:1566:: with SMTP id b35-v6mr15985211plh.107.1530294409466; Fri, 29 Jun 2018 10:46:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530294409; cv=none; d=google.com; s=arc-20160816; b=YzyVYlfRqm8o5Rf9rVmu1w8u3nsqENvMigGx3KKSoEqpu1taqYdAUCW9aGt/l/hQ3p /CEgXSnycMgZ5RLMEbv6J1bfYAXcD920ihO3tCNbFZ3s3NVeF6U1TrWIWStgaReM4ICg jVELqydFTEIDLrGg1vxSFw1J5iPeF6uSy9u35L0J0VF4DR+qBfaGqHH7V1xeavY+I4he jhtJMy9Sb6JJ6lgB1gZHfuakUX6vDLc7Y3JvuYhnW8varrKI0AiTUP8vSid263o7FD+0 w2USflPnkd08hudPqcULKxbDVwusqp9o7r/ZMewVZbA0JJ+Is3YmlV+LV6UOVzsK7vCT zmMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=aJohm9TmMreKbE7LWhDcI1UEepd4AXXNt4ORjp6O1Hg=; b=yE8iH5+fSrROaNop6UeEXSH84p7pLqp3R5l5WOi0itIYa7ylR4P4BKJEmta2Q/KYqH d93CYoFRmr7NbddVOuQDGcB2uoENKWNonO1fhKT6BTaUDlml0GZ8UxqptFUSP+4l9C/n BkJjspC4qihChxrmnPtb3WW7UIciLsIFGGji98+UKEktmC+7TJ5UTpi8SyK/HMA1Cd4X G//8mUTYdS1JlS0WaZ7l1Gje3m6QI2Xf+pcGu+j6U8KSXQuki29q7kjmsNqCUoOBXcKM Syb3oGIfOq9x2BJNiqQGYmlMt57Biu2d/9/uZVNR4MgLIFUuFYRq8P+W/w1s1nfzMyqI FrVA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v41-v6si9647472plg.451.2018.06.29.10.46.35; Fri, 29 Jun 2018 10:46:49 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755277AbeF2RoX (ORCPT + 99 others); Fri, 29 Jun 2018 13:44:23 -0400 Received: from mx2.suse.de ([195.135.220.15]:39132 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755232AbeF2RoU (ORCPT ); Fri, 29 Jun 2018 13:44:20 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 68073AD97; Fri, 29 Jun 2018 17:44:18 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 735F01E3C1A; Fri, 29 Jun 2018 19:44:15 +0200 (CEST) Date: Fri, 29 Jun 2018 19:44:15 +0200 From: Jan Kara To: Shakeel Butt Cc: Jan Kara , Andrew Morton , Michal Hocko , Johannes Weiner , Vladimir Davydov , Jan Kara , Greg Thelen , Amir Goldstein , Roman Gushchin , Alexander Viro , LKML , Cgroups , linux-fsdevel , Linux MM Subject: Re: [PATCH 1/2] fs: fsnotify: account fsnotify metadata to kmemcg Message-ID: <20180629174415.edjickzrvascp43d@quack2.suse.cz> References: <20180627191250.209150-1-shakeelb@google.com> <20180627191250.209150-2-shakeelb@google.com> <20180628100253.jscxkw2d6vfhnbo5@quack2.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170912 (1.9.0) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 28-06-18 12:21:26, Shakeel Butt wrote: > On Thu, Jun 28, 2018 at 12:03 PM Jan Kara wrote: > > > > On Wed 27-06-18 12:12:49, Shakeel Butt wrote: > > > A lot of memory can be consumed by the events generated for the huge or > > > unlimited queues if there is either no or slow listener. This can cause > > > system level memory pressure or OOMs. So, it's better to account the > > > fsnotify kmem caches to the memcg of the listener. > > > > > > However the listener can be in a different memcg than the memcg of the > > > producer and these allocations happen in the context of the event > > > producer. This patch introduces remote memcg charging API which the > > > producer can use to charge the allocations to the memcg of the listener. > > > > > > There are seven fsnotify kmem caches and among them allocations from > > > dnotify_struct_cache, dnotify_mark_cache, fanotify_mark_cache and > > > inotify_inode_mark_cachep happens in the context of syscall from the > > > listener. So, SLAB_ACCOUNT is enough for these caches. > > > > > > The objects from fsnotify_mark_connector_cachep are not accounted as they > > > are small compared to the notification mark or events and it is unclear > > > whom to account connector to since it is shared by all events attached to > > > the inode. > > > > > > The allocations from the event caches happen in the context of the event > > > producer. For such caches we will need to remote charge the allocations > > > to the listener's memcg. Thus we save the memcg reference in the > > > fsnotify_group structure of the listener. > > > > > > This patch has also moved the members of fsnotify_group to keep the size > > > same, at least for 64 bit build, even with additional member by filling > > > the holes. > > > > ... > > > > > static int __init fanotify_user_setup(void) > > > { > > > - fanotify_mark_cache = KMEM_CACHE(fsnotify_mark, SLAB_PANIC); > > > + fanotify_mark_cache = KMEM_CACHE(fsnotify_mark, > > > + SLAB_PANIC|SLAB_ACCOUNT); > > > fanotify_event_cachep = KMEM_CACHE(fanotify_event_info, SLAB_PANIC); > > > if (IS_ENABLED(CONFIG_FANOTIFY_ACCESS_PERMISSIONS)) { > > > fanotify_perm_event_cachep = > > > > Why don't you setup also fanotify_event_cachep and > > fanotify_perm_event_cachep caches with SLAB_ACCOUNT and instead specify > > __GFP_ACCOUNT manually? Otherwise the patch looks good to me. > > > > Hi Jan, IMHO having a visible __GFP_ACCOUNT along with > memalloc_use_memcg() makes the code more explicit and readable that we > want to targeted/remote memcg charging. However if you think > otherwise, I will replace __GFP_ACCOUNT with SLAB_ACCOUNT. OK, fair enough. Honza -- Jan Kara SUSE Labs, CR