From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f68.google.com ([74.125.82.68]:33558 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752259AbcLLSSb (ORCPT ); Mon, 12 Dec 2016 13:18:31 -0500 Received: by mail-wm0-f68.google.com with SMTP id u144so12937694wmu.0 for ; Mon, 12 Dec 2016 10:18:31 -0800 (PST) From: edward.shishkin@gmail.com To: Eric Van Hensbergen , V9FS Developers Mailing List , Linux Filesystem Development List Cc: QEMU Developers Mailing List , ZhangWei , Claudio Fontana , Greg Kurz , Alexander Graf , Eduard Shishkin Subject: [PATCH 7/7] 9p: v9fs fix calculation of max number of merged pages Date: Mon, 12 Dec 2016 19:15:42 +0100 Message-Id: <1481566542-25894-7-git-send-email-edward.shishkin@gmail.com> In-Reply-To: <1481566542-25894-1-git-send-email-edward.shishkin@gmail.com> References: <1481566542-25894-1-git-send-email-edward.shishkin@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: From: Eduard Shishkin Don't merge too many pages when composing a 9p message because: . it doesn't lead to essential performance improvement; . to not allow user space to allocate big amount of kernel memory. We use a limit of 256K (for total size of all pages merged per message), as larger values don't provide any visible speedup. Signed-off-by: Eduard Shishkin --- fs/9p/v9fs.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index 58bff9e..50a4034 100644 --- a/fs/9p/v9fs.c +++ b/fs/9p/v9fs.c @@ -319,6 +319,8 @@ void put_flush_set(struct v9fs_flush_set *fset) kfree(fset); } +#define MAX_FLUSH_DATA_SIZE (262144) + /** * Allocate and initalize flush set * Pre-conditions: valid msize is set @@ -333,6 +335,11 @@ int alloc_init_flush_set(struct v9fs_session_info *v9ses) if (num_pages < 2) /* speedup impossible */ return 0; + if (num_pages > (MAX_FLUSH_DATA_SIZE >> PAGE_SHIFT)) + /* + * no performance gain with larger values + */ + num_pages = MAX_FLUSH_DATA_SIZE >> PAGE_SHIFT; fset = kzalloc(sizeof(*fset), GFP_KERNEL); if (!fset) goto error; -- 2.7.4