Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2447958ybv; Mon, 24 Feb 2020 05:30:31 -0800 (PST) X-Google-Smtp-Source: APXvYqxpfAySjNxIJIYpxLstD8F8+YaltQRoiktmPuG3BlwI4usyeq/PpgvQVXysjBZBzdBvQpn1 X-Received: by 2002:a05:6830:1e76:: with SMTP id m22mr36025443otr.295.1582551031282; Mon, 24 Feb 2020 05:30:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582551031; cv=none; d=google.com; s=arc-20160816; b=rNYAAQ+tQW4IK7Cg35KzJ+LKdncL4hGZVbBHHosEu0WTiCAI84k/8bfXWL01s5FfUm AojDSWuka7KNJ3U9wv91TSM9rTILmCCcPUZRMII96n1RpA42oKyKvXLMmvWOS4lonuAe 14qsbAhFnA3RcDllhSKT8P2mCXIS5VfgvqMraTtgl0regoD4WkpKkjUgvgi6gWFjO/31 IIOT0pcdBykftdOdTl16aVGp/tsnqJ6uz5mi4UPrirhk57fx8PcXhpZecHUJWPDWWmUI 3t4tbexFmlKhOxyERJv0SKIi4Wh1rOi5huSvzWnX+jAZSCGx6aI1VWypIf9NPHnki4x1 s4Yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:subject:message-id:date:from :mime-version:dkim-signature; bh=nXap8ruoJmQKUv4CaZGUjHx6jvvxzBsJg2NNbHNKxQI=; b=C2JQDuSXmMr8a24FeoB5CfSs/1RyNZ6WWupRd2+LHAOwfWzGXdHypGwSEFL7oZ6Jun gxc56xnQtdq8C91Ud9OVUnEAqIuVZfDGwllP3EZM9SWak1XRdVI6PYyAtXbg1Lsi6o3a PRGRFtfKAyD4hf6IE0tQuWtX6ZcrVZvLnO3l2F13QiXEH4V90jvLUZbriKIje2oO9Efs lm8AXyheZ2adTDZb351XJ2tNXdiyOawVqr5MNXFEUQ2SvXqhhb4fdoR35gwBoqYsjrzg l26Uq7KpcyNcbWSE3VyPw0mvP271MJBt74PoB9oiGC5quAILJc7H6IrzV1EkRXzeqhZZ IFbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@stapelberg-ch.20150623.gappssmtp.com header.s=20150623 header.b=m8G5HZMb; 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 e23si5022628oie.105.2020.02.24.05.30.18; Mon, 24 Feb 2020 05:30:31 -0800 (PST) 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; dkim=pass header.i=@stapelberg-ch.20150623.gappssmtp.com header.s=20150623 header.b=m8G5HZMb; 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 S1727438AbgBXN33 (ORCPT + 99 others); Mon, 24 Feb 2020 08:29:29 -0500 Received: from mail-oi1-f196.google.com ([209.85.167.196]:35499 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727064AbgBXN33 (ORCPT ); Mon, 24 Feb 2020 08:29:29 -0500 Received: by mail-oi1-f196.google.com with SMTP id b18so8918862oie.2 for ; Mon, 24 Feb 2020 05:29:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stapelberg-ch.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=nXap8ruoJmQKUv4CaZGUjHx6jvvxzBsJg2NNbHNKxQI=; b=m8G5HZMbWY4YSd5U1wyMqaxMB37vSbxOyTgmaGDnw+WSPp5PJwEfDTILdQUV8cE6L0 yNgQ67/h331ehCJAkg5aTWAZnfuX9O4q34SXM+X7/SYEPbYqW34E4KZm2Tkgn3RE3kHz 510tyHVzQkWBywV5eGhZgkLPkbXSHtV+GGAw7dC61fLBO9B9KedNbgts455XIJYwKScT 9UoEI1//fRO56ZtkCiL3s1+9duXMATRA0rhVL9kR0SLpHMQWvkSVSgepPBFJjDb3yWz7 kyO/W4jsxukxctF9aJM8WYUNv7cZ0J9AtS4Od2+Y3hQOzKOdV8oLtn+CgFEVcaDD6Xgz 8h4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=nXap8ruoJmQKUv4CaZGUjHx6jvvxzBsJg2NNbHNKxQI=; b=eG3wDt6Fgp59t01ZnzEinbn7k0SVhc6AWycFCCWXj5GepmWeIZMmn81KCnXZ06qb6l BtBwYFZlgaTVZwET6S/4rm47fCcglGn3RPelZ7jA2TvMvIyv0Y7hskatYd6nFVpnDRg/ v6MPvmJz0wMOCtgFL11yQRGGNV3Jvl22fIM7CnwjKnWLkmYJ4HZSMzTPP94WbXjFlC1Q 3n5SYi+MYwtPcCZ8sOt/nhD1lXYM7c4y7ATgaG8FO2nXQvYhVUeLngKNJSlw2s54fM8f 0BcOh23aVVwNHF1HwrBf1XqDimF+FtdMZx/TVK+DbjOh+agio6wKOIe4Dv9UbNhjjx57 Eamg== X-Gm-Message-State: APjAAAViH2tl/m3IJfqpmsfD+qPsETBZPJVHmGWTKf6W+ujkEBNUcCuY Ao03z1PQRl9PRSzTCWjkDz7yYba1iIgYiiNvr9Q4lA== X-Received: by 2002:aca:cc07:: with SMTP id c7mr12168055oig.165.1582550966813; Mon, 24 Feb 2020 05:29:26 -0800 (PST) MIME-Version: 1.0 From: Michael Stapelberg Date: Mon, 24 Feb 2020 14:29:15 +0100 Message-ID: Subject: Writing to FUSE via mmap extremely slow (sometimes) on some machines? To: fuse-devel , Miklos Szeredi , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: multipart/mixed; boundary="0000000000003777a4059f525cbe" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --0000000000003777a4059f525cbe Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hey, I=E2=80=99m running into an issue where writes via mmap are extremely slow. The mmap program I=E2=80=99m using to test is attached. The symptom is that the program usually completes in 0.x seconds, but then sometimes takes minutes to complete! E.g.: % dd if=3D/dev/urandom of=3D/tmp/was bs=3D1M count=3D99 % ./fusexmp_fh /tmp/mnt % time ~/mmap /tmp/was /tmp/mnt/tmp/stapelberg.1 Mapped src: 0x10000 and dst: 0x21b8b000 memcpy done ~/mmap /tmp/was /tmp/mnt/tmp/stapelberg.1 0.06s user 0.20s system 48% cpu 0.544 total % time ~/mmap /tmp/was /tmp/mnt/tmp/stapelberg.1 Mapped src: 0x10000 and dst: 0x471fb000 memcpy done ~/mmap /tmp/was /tmp/mnt/tmp/stapelberg.1 0.05s user 0.22s system 0% cpu 2:03.39 total This affects both an in-house FUSE file system and also FUSE=E2=80=99s fusexmp_fh from 2.9.7 (matching what our in-house FS uses). While this is happening, the machine is otherwise idle. E.g. dstat shows: --total-cpu-usage-- -dsk/total- -net/total- ---paging-- ---system-- usr sys idl wai stl| read writ| recv send| in out | int csw 1 0 98 1 0| 0 0 | 19k 23k| 0 0 | 14k 27k 1 0 98 1 0| 0 0 | 33k 53k| 0 0 | 14k 29k 0 0 98 1 0| 0 176k| 27k 26k| 0 0 | 13k 25k [=E2=80=A6] While this is happening, using cp(1) to copy the same file is fast (1 second). It=E2=80=99s only mmap-based writing that=E2=80=99s slow. This is with Linux 5.2.17, but has been going on for years apparently. I haven=E2=80=99t quite figured out what the pattern is with regards to the machines that are affected. One wild guess I have is that it might be related to RAM? The machine on which I can most frequently reproduce the issue has 192GB of RAM, whereas I haven=E2=80=99t been able to reproduc= e the issue on my workstation with 64GB of RAM. Any ideas what I could check to further narrow down this issue? Thanks, --0000000000003777a4059f525cbe Content-Type: text/x-csrc; charset="US-ASCII"; name="mmap.c" Content-Disposition: attachment; filename="mmap.c" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_k70g91jk0 I2luY2x1ZGUgPHN5cy90eXBlcy5oPgojaW5jbHVkZSA8c3lzL3N0YXQuaD4KI2luY2x1ZGUgPHN5 cy9tbWFuLmg+IAojaW5jbHVkZSA8ZmNudGwuaD4KI2luY2x1ZGUgPHN0cmluZy5oPgojaW5jbHVk ZSA8c3RkaW8uaD4KI2luY2x1ZGUgPHN0ZGxpYi5oPgojaW5jbHVkZSA8dW5pc3RkLmg+CgovKgog KiBBbiBpbXBsZW1lbnRhdGlvbiBvZiBjb3B5ICgiY3AiKSB0aGF0IHVzZXMgbWVtb3J5IG1hcHMu ICBWYXJpb3VzCiAqIGVycm9yIGNoZWNraW5nIGhhcyBiZWVuIHJlbW92ZWQgdG8gcHJvbW90ZSBy ZWFkYWJpbGl0eQogKi8KCi8vIFdoZXJlIHdlIHdhbnQgdGhlIHNvdXJjZSBmaWxlJ3MgbWVtb3J5 IG1hcCB0byBsaXZlIGluIHZpcnR1YWwgbWVtb3J5Ci8vIFRoZSBkZXN0aW5hdGlvbiBmaWxlIHJl c2lkZXMgaW1tZWRpYXRlbHkgYWZ0ZXIgdGhlIHNvdXJjZSBmaWxlCiNkZWZpbmUgTUFQX0xPQ0FU SU9OIDB4NjEwMAoKaW50IG1haW4gKGludCBhcmdjLCBjaGFyICphcmd2W10pIHsKIGludCBmZGlu LCBmZG91dDsKIGNoYXIgKnNyYywgKmRzdDsKIHN0cnVjdCBzdGF0IHN0YXRidWY7CiBvZmZfdCBm aWxlU2l6ZSA9IDA7CgogaWYgKGFyZ2MgIT0gMykgewogICBwcmludGYgKCJ1c2FnZTogYS5vdXQg PGZyb21maWxlPiA8dG9maWxlPlxuIik7CiAgIGV4aXQoMCk7CiB9CgogLyogb3BlbiB0aGUgaW5w dXQgZmlsZSAqLwogaWYgKChmZG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