Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp38680imm; Thu, 28 Jun 2018 13:27:43 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJHF23agovIrPUqsoDjs2oI+1/G/R9DE3/VF7+Ek059aD4SHVn7Zq5sKllyKlGJC2hbzsqo X-Received: by 2002:a17:902:76c4:: with SMTP id j4-v6mr11747083plt.19.1530217663237; Thu, 28 Jun 2018 13:27:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530217663; cv=none; d=google.com; s=arc-20160816; b=qaM1ojE41hxqtG6sUS/yKt5fA5/Z7YCEhsWNFyRMtqjeDcybvIAbLEmIUyEimfsKfT 9LjItnqAaO7Gb238WxzQM1YlWjAAgElmz9xBeG8o7sJDEcEhWYpPP4P9yI8f1XTCGxfP ujPXZfdjhe4C+bCTqaOxrBwtY3HYKIWvqSjtyS8Co9G3IqyNDdnMVe7p8E7Iza3ZoQiF 2Mb0CJhHcFxidJ0Wzy+sQj35IeNL1XSyVfNvVxyFQy6PikY3twZRsk70iIngDSkoLbp+ iNDAW6W9LhXyeD/Q2ansmX5+UEiA3gEgsiHTcQ89/admJ1eogbhvYzf1ha4o2G7fyCPI 9DTQ== 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=8b39DexMZRQt6Tg+eBwKbCA/cWjXX2Ietpbba+bK+M0=; b=oWPF+oP6XHL6/LioHINdPFUaqC2DBKveI013N2GRzMBJPxQPv1RkWKe4cXG1u5Y+9i cZyYBwlmVnNguOsvIFB5srZiHI0b1sfQpIo//VrDh8Qr92Ir5nO8+2trHtUxWq1o18nr Odw95c/qG3eMa3DTT//EfPQRH8rIaSg71S9JQ8Qe7gfp3RPtezimXaO+qzpULMHQ36RP hB0lUgAZbHi5qJOYAAYYU5pGwAFSReNUerWXgTkGV7jIvn8Jdc903JfSFcBoEN/BkwIx nUxu2ab6pAM6IYi49uc9CoB1FmfXWd5JH/7/k/z+llW2er6/Vn0zFY+iAn/FwhyH+rjk sOMg== 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 j13-v6si1370557pgt.442.2018.06.28.13.27.26; Thu, 28 Jun 2018 13:27:43 -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 S968006AbeF1TDi (ORCPT + 99 others); Thu, 28 Jun 2018 15:03:38 -0400 Received: from mx2.suse.de ([195.135.220.15]:38030 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754605AbeF1TDb (ORCPT ); Thu, 28 Jun 2018 15:03:31 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A6E15ACCF; Thu, 28 Jun 2018 19:03:27 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 316641E3C15; Thu, 28 Jun 2018 12:02:53 +0200 (CEST) Date: Thu, 28 Jun 2018 12:02:53 +0200 From: Jan Kara To: Shakeel Butt Cc: Andrew Morton , Michal Hocko , Johannes Weiner , Vladimir Davydov , Jan Kara , Greg Thelen , Amir Goldstein , Roman Gushchin , Alexander Viro , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Jan Kara Subject: Re: [PATCH 1/2] fs: fsnotify: account fsnotify metadata to kmemcg Message-ID: <20180628100253.jscxkw2d6vfhnbo5@quack2.suse.cz> References: <20180627191250.209150-1-shakeelb@google.com> <20180627191250.209150-2-shakeelb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180627191250.209150-2-shakeelb@google.com> 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 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. Honza -- Jan Kara SUSE Labs, CR