Message ID | 20240228144126.2864064-1-houtao@huaweicloud.com |
---|---|
Headers |
Return-Path: <linux-kernel+bounces-85195-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3389003dyb; Wed, 28 Feb 2024 06:42:17 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUUfQ0ILqfG/1xZ2DRYw7TU4qbuDCjA8YD9WU1yRrlpU0b5ZuR07hSEYCwI52nuE2om/aDBOnUPDVNohwEztYhdCxL5VQ== X-Google-Smtp-Source: AGHT+IFkng+s1yxR/zeAxxmEZMi/Ug5uBpQudje141YEXKNqOgiTH10plPOixneEHEye/aAF2Koc X-Received: by 2002:aa7:c985:0:b0:564:fe7c:2 with SMTP id c5-20020aa7c985000000b00564fe7c0002mr6359624edt.36.1709131337716; Wed, 28 Feb 2024 06:42:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709131337; cv=pass; d=google.com; s=arc-20160816; b=rS+sejNpL3ZD6Zr9K0vCs8OUr00Bg/uV0av6U/ovGYYSwScU/Hwt7Q9z3WxczCKuf8 QHhlYgwqy+dw2Q7mcna4ZvP9OiYRnrIyT4qEhqTG+k5o77oFuNQ2U3JMBBsMrJcM9lbm 55mYMEf7JLg5sZz/xfrHiO0YQy3N1SD7+vlJMvdHr/kjR7ksUZailfYdREm6P/dWzal9 BIhuqOI+AnvF2ZpWmnVT5dVZBSXVdWYqkvsWSM+KVXaPoy/bWC2E3np3ro3bPsUEEJoj KcHkapvmse4pJ5kSts8OPKwwxu3VrJpKLpzr4/lT+XwVIkWmNbrwsfkHMuGrq+0sqk7X KZEw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=KuFWObdCaN9ab9zwr1uZWzG84KoouI1VevNiyaMwUAA=; fh=kBUQxOlp+QIPoGMgo10Oj9GWEhqsOQqiyuOEYaOGoxg=; b=cexG5XRnWw+VdvNaOQIM23MVe08nQQCez8a/bmq67G7D+o1Tvy5IK50fI2W+57bfk1 sblxe7slmRMmVtJoBIhRlvcofXqYrTL1Y0IsPlquqnlJ7/cc7LrcvaC+MlmtMKk28780 VGrLxbjWyFLw2/BRhSdG/cylcQ6ILyLmONRmvCd02R19CXXwMZa0Tds5nk4gXoOT0EJv 2RUxjaMtV58Du5FrWf0zCmK9X2FxLyWpxBgTHcN4vONl55Z3ZpzPp4S368Xyu0EFrjUe yrM882N0Koocl+k07j1rY5Espq0EF2bgy1Ki06vNO5t5cHA96K7ZqYwkcUdSl7CGF45b tAJQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-85195-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85195-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id p1-20020a056402074100b005655c8dc230si1702526edy.140.2024.02.28.06.42.17 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 06:42:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85195-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-85195-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85195-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 570341F25007 for <ouuuleilei@gmail.com>; Wed, 28 Feb 2024 14:42:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2177415D5D5; Wed, 28 Feb 2024 14:40:51 +0000 (UTC) Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6809415A4AE; Wed, 28 Feb 2024 14:40:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709131249; cv=none; b=Mu7arhBW387g8vlpSgPZOsQipCOfa81PQE8+1uexYuDhSdqpkjYxvjop5FRerFzi4/ozqcHoui286mn0yOJCPoSQJ0pxqPcm7pr/4UKb2zvOj/f0RdHdDVGFVrGETfnPmPwaMY1jpzjJ6gtCtYw7OyvGzli6aiB/LsZcCV/WKMs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709131249; c=relaxed/simple; bh=XHXeXaJRpFl8dTOB0fKC2pb2+NvmS7IshikIKOOpEW4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=No1rggB2K1hloGbW2mKR+maCalv4l2SHjGABmNvOZN0l+NE/D2wW+LeX1YfpR3+oUzWpCrAvX+SWpE1tOjGTCfkU9A+ISWm8C+46cD7FMIU+4SRHI7alz0wE08L/9tMZHI6vARTu0Huz2AvhVe++6CgVPghKVx6iR9PSAE2oi3k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4TlH8L6K18z4f3l1V; Wed, 28 Feb 2024 22:40:34 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 393841A0568; Wed, 28 Feb 2024 22:40:42 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP1 (Coremail) with SMTP id cCh0CgBnOBHkRd9lwGKzFQ--.18779S4; Wed, 28 Feb 2024 22:40:37 +0800 (CST) From: Hou Tao <houtao@huaweicloud.com> To: linux-fsdevel@vger.kernel.org Cc: Miklos Szeredi <miklos@szeredi.hu>, Vivek Goyal <vgoyal@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>, Bernd Schubert <bernd.schubert@fastmail.fm>, "Michael S . Tsirkin" <mst@redhat.com>, Matthew Wilcox <willy@infradead.org>, Benjamin Coddington <bcodding@redhat.com>, linux-kernel@vger.kernel.org, virtualization@lists.linux.dev, houtao1@huawei.com Subject: [PATCH v2 0/6] virtiofs: fix the warning for ITER_KVEC dio Date: Wed, 28 Feb 2024 22:41:20 +0800 Message-Id: <20240228144126.2864064-1-houtao@huaweicloud.com> X-Mailer: git-send-email 2.29.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: cCh0CgBnOBHkRd9lwGKzFQ--.18779S4 X-Coremail-Antispam: 1UD129KBjvJXoWxZryxAw4xAF45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RID: 1792154101267198369 X-GMAIL-MSGID: 1792154101267198369 |
Series |
virtiofs: fix the warning for ITER_KVEC dio
|
|
Message
Hou Tao
Feb. 28, 2024, 2:41 p.m. UTC
From: Hou Tao <houtao1@huawei.com>
Hi,
The patch set aims to fix the warning related to an abnormal size
parameter of kmalloc() in virtiofs. The warning occurred when attempting
to insert a 10MB sized kernel module kept in a virtiofs with cache
disabled. As analyzed in patch #1, the root cause is that the length of
the read buffer is no limited, and the read buffer is passed directly to
virtiofs through out_args[0].value. Therefore patch #1 limits the
length of the read buffer passed to virtiofs by using max_pages. However
it is not enough, because now the maximal value of max_pages is 256.
Consequently, when reading a 10MB-sized kernel module, the length of the
bounce buffer in virtiofs will be 40 + (256 * 4096), and kmalloc will
try to allocate 2MB from memory subsystem. The request for 2MB of
physically contiguous memory significantly stress the memory subsystem
and may fail indefinitely on hosts with fragmented memory. To address
this, patch #2~#5 use scattered pages in a bio_vec to replace the
kmalloc-allocated bounce buffer when the length of the bounce buffer for
KVEC_ITER dio is larger than PAGE_SIZE. The final issue with the
allocation of the bounce buffer and sg array in virtiofs is that
GFP_ATOMIC is used even when the allocation occurs in a kworker context.
Therefore the last patch uses GFP_NOFS for the allocation of both sg
array and bounce buffer when initiated by the kworker. For more details,
please check the individual patches.
As usual, comments are always welcome.
Change Log:
v2:
* limit the length of ITER_KVEC dio by max_pages instead of the
newly-introduced max_nopage_rw. Using max_pages make the ITER_KVEC
dio being consistent with other rw operations.
* replace kmalloc-allocated bounce buffer by using a bounce buffer
backed by scattered pages when the length of the bounce buffer for
KVEC_ITER dio is larger than PAG_SIZE, so even on hosts with
fragmented memory, the KVEC_ITER dio can be handled normally by
virtiofs. (Bernd Schubert)
* merge the GFP_NOFS patch [1] into this patch-set and use
memalloc_nofs_{save|restore}+GFP_KERNEL instead of GFP_NOFS
(Benjamin Coddington)
v1: https://lore.kernel.org/linux-fsdevel/20240103105929.1902658-1-houtao@huaweicloud.com/
[1]: https://lore.kernel.org/linux-fsdevel/20240105105305.4052672-1-houtao@huaweicloud.com/
Hou Tao (6):
fuse: limit the length of ITER_KVEC dio by max_pages
virtiofs: move alloc/free of argbuf into separated helpers
virtiofs: factor out more common methods for argbuf
virtiofs: support bounce buffer backed by scattered pages
virtiofs: use scattered bounce buffer for ITER_KVEC dio
virtiofs: use GFP_NOFS when enqueuing request through kworker
fs/fuse/file.c | 12 +-
fs/fuse/virtio_fs.c | 336 +++++++++++++++++++++++++++++++++++++-------
2 files changed, 296 insertions(+), 52 deletions(-)