From patchwork Mon Sep 16 23:56:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Khazhy Kumykov X-Patchwork-Id: 11147961 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EE6CA912 for ; Mon, 16 Sep 2019 23:57:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CCB62206A4 for ; Mon, 16 Sep 2019 23:57:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="e9oyZttD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729187AbfIPX4z (ORCPT ); Mon, 16 Sep 2019 19:56:55 -0400 Received: from mail-pg1-f201.google.com ([209.85.215.201]:33051 "EHLO mail-pg1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728891AbfIPX4y (ORCPT ); Mon, 16 Sep 2019 19:56:54 -0400 Received: by mail-pg1-f201.google.com with SMTP id a13so828582pgw.0 for ; Mon, 16 Sep 2019 16:56:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=Nv3cd1IYe218SOJZ3rC1Ee+aio0oZ4eC7xZJKuNaKOc=; b=e9oyZttDjlw6tCTjIe9uniqS4kOdfIabqbhx1chZejA60M5S0NDjV/PsGhbqgYK7ef GAb7Lcq3xoymFXFpjBooWkO09+zmZAckg3+B3WBtTOJ0d0FtLICRIWKxD1VgUWPm6n+S eD5y9Ikk6kYgR7JrBVRjRPaQaWncrXsx/5ea4BzV8zEyprpxiExn0bfMdmhiQUPQrke6 tcUz5kFzHuFVaKcq8rButlqvmJgi3v2ZloJdouSkRQMlF7lLww2PfeueFbsSoj5h978F UHoCywQaikvMielqyOYIQ7NlEFhdEH1Cjtk0Nhvj/ZMjMAlJ0yxuOkPKlYKCpHNW9qFb njZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=Nv3cd1IYe218SOJZ3rC1Ee+aio0oZ4eC7xZJKuNaKOc=; b=Um4CJmn5ui0JBO1Mn6xdG+Lf6Z77wfhXcjOxRtfWLmj5f2GxhqNhV2YLgRZf7jdwIh X6dG06zvIUV1rbc4oTTZCCJqcsFDftxPDG8PGZhZ1G+gQeIBgnsvXPhP9AxccWva2t8u hPguRXGYARRR5ewJWhLZb9HNvOFiye89ecnhzHOdwXSSxJP5joMJ32k1Meuu87sXOEmU 8FxQvlJrmjkiIVQ3mpSpfoGiWVC5URAcIuLG2Ch6nhyeDqNeQT3dbKJhnP2lp8Y4VRRH 2VlH262p0SXRKJvtYK5x+9NJNttIe1lTkM1UHHjPVEd0NKyIXqDltcrvYaYe0SmaldyB EGxg== X-Gm-Message-State: APjAAAUqJelqK9+ef8wDaO1KaaiE0gpD2Ccd7HHTJ5x28qyRuwpU/v6x 5h0c/vjvtwPlOGJ4HNc9B3GRZEe3hXI= X-Google-Smtp-Source: APXvYqz+hphq3WGD6WehGtvk6AFKKPR4czIFl0zAfO/NuPMCoLT4QWM5pH4oEkWl3FGInOapFrpl6SFIi4s= X-Received: by 2002:a63:d608:: with SMTP id q8mr722520pgg.422.1568678212226; Mon, 16 Sep 2019 16:56:52 -0700 (PDT) Date: Mon, 16 Sep 2019 16:56:41 -0700 Message-Id: <20190916235642.167583-1-khazhy@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.23.0.237.gc6a4ce50a0-goog Subject: [PATCH v3 1/2] fuse: on 64-bit store time in d_fsdata directly From: Khazhismel Kumykov To: miklos@szeredi.hu Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, shakeelb@google.com, Khazhismel Kumykov Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Implements the optimization noted in f75fdf22b0a8 ("fuse: don't use ->d_time"), as the additional memory can be significant. (In particular, on SLAB configurations this 8-byte alloc becomes 32 bytes). Per-dentry, this can consume significant memory. Reviewed-by: Shakeel Butt Signed-off-by: Khazhismel Kumykov --- v3: reapplied on fuse/for-next, droping the fuse_request_alloc refactor it was already done :) (and account new per-file alloc) fs/fuse/dir.c | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index ba0a175d7578..58557d4817e9 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -24,11 +24,34 @@ static void fuse_advise_use_readdirplus(struct inode *dir) set_bit(FUSE_I_ADVISE_RDPLUS, &fi->state); } +#if BITS_PER_LONG >= 64 +static inline void __fuse_dentry_settime(struct dentry *entry, u64 time) +{ + entry->d_fsdata = (void *) time; +} + +static inline u64 fuse_dentry_time(const struct dentry *entry) +{ + return (u64)entry->d_fsdata; +} + +#else union fuse_dentry { u64 time; struct rcu_head rcu; }; +static inline void __fuse_dentry_settime(struct dentry *dentry, u64 time) +{ + ((union fuse_dentry *) dentry->d_fsdata)->time = time; +} + +static inline u64 fuse_dentry_time(const struct dentry *entry) +{ + return ((union fuse_dentry *) entry->d_fsdata)->time; +} +#endif + static void fuse_dentry_settime(struct dentry *dentry, u64 time) { struct fuse_conn *fc = get_fuse_conn_super(dentry->d_sb); @@ -47,12 +70,7 @@ static void fuse_dentry_settime(struct dentry *dentry, u64 time) spin_unlock(&dentry->d_lock); } - ((union fuse_dentry *) dentry->d_fsdata)->time = time; -} - -static inline u64 fuse_dentry_time(const struct dentry *entry) -{ - return ((union fuse_dentry *) entry->d_fsdata)->time; + __fuse_dentry_settime(dentry, time); } /* @@ -258,6 +276,7 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags) goto out; } +#if BITS_PER_LONG < 64 static int fuse_dentry_init(struct dentry *dentry) { dentry->d_fsdata = kzalloc(sizeof(union fuse_dentry), GFP_KERNEL); @@ -270,6 +289,7 @@ static void fuse_dentry_release(struct dentry *dentry) kfree_rcu(fd, rcu); } +#endif static int fuse_dentry_delete(const struct dentry *dentry) { @@ -279,13 +299,17 @@ static int fuse_dentry_delete(const struct dentry *dentry) const struct dentry_operations fuse_dentry_operations = { .d_revalidate = fuse_dentry_revalidate, .d_delete = fuse_dentry_delete, +#if BITS_PER_LONG < 64 .d_init = fuse_dentry_init, .d_release = fuse_dentry_release, +#endif }; const struct dentry_operations fuse_root_dentry_operations = { +#if BITS_PER_LONG < 64 .d_init = fuse_dentry_init, .d_release = fuse_dentry_release, +#endif }; int fuse_valid_type(int m) From patchwork Mon Sep 16 23:56:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Khazhy Kumykov X-Patchwork-Id: 11147963 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 252A813BD for ; Mon, 16 Sep 2019 23:57:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 03E20206A4 for ; Mon, 16 Sep 2019 23:57:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="sUGJYOj1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729214AbfIPX44 (ORCPT ); Mon, 16 Sep 2019 19:56:56 -0400 Received: from mail-qt1-f202.google.com ([209.85.160.202]:51303 "EHLO mail-qt1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728891AbfIPX44 (ORCPT ); Mon, 16 Sep 2019 19:56:56 -0400 Received: by mail-qt1-f202.google.com with SMTP id e13so1450911qto.18 for ; Mon, 16 Sep 2019 16:56:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=bJmZANwzCFV2Iqz4LhMyBOSdTmADhZHqEPwCse8wah0=; b=sUGJYOj1o9xCwXnv4wc+rHf8HlX3D1AlYIvZvyfihO9GHGvXi79ynXEVh/2RhqczAz W+684pXzoiyFxTsRk9OmIKGhzVP04cxmhPod4hK6vh/4Y6ekcZzsm0U+/20KsWPN+XE7 /fXzxWAz8FiAfivCllUrUfspG4b1EtSjjNZ+pYwcsJLvU4Vip/1+kehaDdo13Zyjiqut aaK9e8E8fR3smRXhz9TtmNYk9W9VrGnNqpOjZPlcM2GH1ylMQYyzoxrB0lGaWQ8fwGSu UiEMQZh272qaXObuaGLMxfyS3y1staHLcfHBXQYkTatdxKpnVEdSJijAeHe8G9DZw6bN JK0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=bJmZANwzCFV2Iqz4LhMyBOSdTmADhZHqEPwCse8wah0=; b=SSaJfWLwJkpK6kvMS4XV91P6Hxa9FuclyF1QSZnZKn7DNXcine3HhTy52jZVLw35eo mFcxDHxMyGpKVqz/N3G3biow/h0JD69+qkPohPqzd0w0MyDRxwW1Z5ZoJ9CjA6hqL8Aq 9YeLu2VY7CatC5DCLHRbjGV9jE0SnhExadQSE2hA26+AMOgXlwjTXKDdYRAYW+BvcAJc hdkJPViVem4+vamyFjULWzczB+G3FOxh7m2W1UWsMVhNZroltg75o7qhb6uncsHubdKG Q6o+T32UIgKgaacuSKCTZYQGw1tsjcmidm+vpGnbtJHhT2aZ3NZmyk+9ZcoMwPvd0772 wRJg== X-Gm-Message-State: APjAAAWbRE0yRFd7yCgbu6OXPnfhihN/LfR1o7vlfdmBKR2sFIqYmcYl 2Ucvh30KH6LzO2BClET8iD80bCzfNrU= X-Google-Smtp-Source: APXvYqwcRpAFsOLDZFs5gKrwwLxNf7Ug2TgXqFTU+omF07IxxIzz4SMFzPqGErLVhC+LGxmgdbZpsHquImU= X-Received: by 2002:aed:3c52:: with SMTP id u18mr1080316qte.194.1568678215490; Mon, 16 Sep 2019 16:56:55 -0700 (PDT) Date: Mon, 16 Sep 2019 16:56:42 -0700 In-Reply-To: <20190916235642.167583-1-khazhy@google.com> Message-Id: <20190916235642.167583-2-khazhy@google.com> Mime-Version: 1.0 References: <20190916235642.167583-1-khazhy@google.com> X-Mailer: git-send-email 2.23.0.237.gc6a4ce50a0-goog Subject: [PATCH v3 2/2] fuse: kmemcg account fs data From: Khazhismel Kumykov To: miklos@szeredi.hu Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, shakeelb@google.com, Khazhismel Kumykov Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org account per-file, dentry, and inode data blockdev/superblock and temporary per-request data was left alone, as this usually isn't accounted Signed-off-by: Khazhismel Kumykov Reviewed-by: Shakeel Butt --- fs/fuse/dir.c | 3 ++- fs/fuse/file.c | 5 +++-- fs/fuse/inode.c | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 58557d4817e9..d572c900bb0f 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -279,7 +279,8 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags) #if BITS_PER_LONG < 64 static int fuse_dentry_init(struct dentry *dentry) { - dentry->d_fsdata = kzalloc(sizeof(union fuse_dentry), GFP_KERNEL); + dentry->d_fsdata = kzalloc(sizeof(union fuse_dentry), + GFP_KERNEL_ACCOUNT | __GFP_RECLAIMABLE); return dentry->d_fsdata ? 0 : -ENOMEM; } diff --git a/fs/fuse/file.c b/fs/fuse/file.c index a2ea347c4d2c..862aff3665b5 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -63,12 +63,13 @@ struct fuse_file *fuse_file_alloc(struct fuse_conn *fc) { struct fuse_file *ff; - ff = kzalloc(sizeof(struct fuse_file), GFP_KERNEL); + ff = kzalloc(sizeof(struct fuse_file), GFP_KERNEL_ACCOUNT); if (unlikely(!ff)) return NULL; ff->fc = fc; - ff->release_args = kzalloc(sizeof(*ff->release_args), GFP_KERNEL); + ff->release_args = kzalloc(sizeof(*ff->release_args), + GFP_KERNEL_ACCOUNT); if (!ff->release_args) { kfree(ff); return NULL; diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 3d598a5bb5b5..6cb445bed89d 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -66,7 +66,8 @@ static struct file_system_type fuseblk_fs_type; struct fuse_forget_link *fuse_alloc_forget(void) { - return kzalloc(sizeof(struct fuse_forget_link), GFP_KERNEL); + return kzalloc(sizeof(struct fuse_forget_link), + GFP_KERNEL_ACCOUNT | __GFP_RECLAIMABLE); } static struct inode *fuse_alloc_inode(struct super_block *sb)