From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C68E2C433EF for ; Sat, 9 Apr 2022 06:08:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DFC8E6B0071; Sat, 9 Apr 2022 02:08:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DAC486B0073; Sat, 9 Apr 2022 02:08:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C73CB6B0074; Sat, 9 Apr 2022 02:08:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id B4ED86B0071 for ; Sat, 9 Apr 2022 02:08:46 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 6AD4D23026 for ; Sat, 9 Apr 2022 06:08:46 +0000 (UTC) X-FDA: 79336311852.04.BA1FEC3 Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) by imf13.hostedemail.com (Postfix) with ESMTP id 0782C20004 for ; Sat, 9 Apr 2022 06:08:45 +0000 (UTC) Received: by mail-qk1-f172.google.com with SMTP id v13so6468913qkv.3 for ; Fri, 08 Apr 2022 23:08:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:in-reply-to:message-id:references :mime-version; bh=6aEcwmX5AHIuIeFqcYJ9jTFQjBEYXnOc4Olxo6nl8Es=; b=NqAdYhsFyqCpaZalKL8cZvkb0ebp2WuRLeZVDMBV9dnaLsD0hT6aMMQ1x2Gpg5345G +yO4oDYXUKqFAIV1Ac/DSJnN2zXSNk8YNat0v8IReqw/zVBgK8uPe1r4NjZWVWpybJU8 dxf17wqIuahDlUYc1qEYdIrSo3YAZW/0uhEIvBdge44SZvyrjc/FGu+9F30AUhpazNQM UFO3izbcSbwR/kjPjgh+nyLiXzzlrRhudOVIhUrYpHG12yE+zu6lyoM90VBvW0GkHG6I ycykZh/XGWDW1qht46NE/BNnl/k2pgdvpjPmGyaU5zqIq52WH9JWnyILe48+6gOEaknW tGxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:mime-version; bh=6aEcwmX5AHIuIeFqcYJ9jTFQjBEYXnOc4Olxo6nl8Es=; b=IXzaT6dXkpVQQ3ZOVSeJg5wiMkvO1ysK/cv4CjDWEu/sd0/uo85v3n5GhCoy/lYBqG 0h/IsRi85aNbAbcOGIEKye9KR7HctXT2ttGYf45MowJMv68ngBa0C8vv8eymBtZa60jb 1N7/Bxkymhxhgptmk3tYaQAVBK8dakUT50L7nd9SqPoNBxkLrR8hl8uv3zmw2CNPMrR0 +HZRJYS0BVOp5/PoBK5ZOnINxDRIygOeCXmLOWdfzh/Oc7hmoJSD9QW0qp3Mk1bahcGf tkhRxI8Wg2lDMwI67DOnJk5ZRW9xP1kBw9226WL3TZMivEwU892Sj/T0NZusi90IlbZL Kq8w== X-Gm-Message-State: AOAM531I9iaLeOKlHZQ+hpKZIUypHKAX1vX0sdP7QuLGSgp5GAZhYdh3 Hdyb3vzX6QpdMj+krEj2rNojfA== X-Google-Smtp-Source: ABdhPJwB4d7Ufi4cN4i+wikQ8L0VsgopVFCWZFF2+UtgD8fK4o0ibgOxwGW6k02yNhdIRgCp/83Ksg== X-Received: by 2002:a05:620a:d87:b0:67b:311c:ecbd with SMTP id q7-20020a05620a0d8700b0067b311cecbdmr15327968qkl.146.1649484525161; Fri, 08 Apr 2022 23:08:45 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id p5-20020a378d05000000b0069beaffd5b3sm1849345qkd.4.2022.04.08.23.08.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Apr 2022 23:08:44 -0700 (PDT) Date: Fri, 8 Apr 2022 23:08:29 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.anvils To: Christoph Hellwig cc: Hugh Dickins , Andrew Morton , Chuck Lever III , Mark Hemment , Patrice CHOTARD , Mikulas Patocka , Lukas Czerner , "Darrick J. Wong" , "Jason A. Donenfeld" , Borislav Petkov , linux-mm@kvack.org, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, viro@zeniv.linux.org.uk Subject: Re: [PATCH] tmpfs: fix regressions from wider use of ZERO_PAGE In-Reply-To: <20220409050638.GB17755@lst.de> Message-ID: References: <9a978571-8648-e830-5735-1f4748ce2e30@google.com> <20220409050638.GB17755@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 0782C20004 X-Rspam-User: Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=NqAdYhsF; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf13.hostedemail.com: domain of hughd@google.com designates 209.85.222.172 as permitted sender) smtp.mailfrom=hughd@google.com X-Stat-Signature: i7dsyq4kdmfg45kyn55nfkccasud8dfd X-HE-Tag: 1649484525-783380 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sat, 9 Apr 2022, Christoph Hellwig wrote: > On Fri, Apr 08, 2022 at 01:38:41PM -0700, Hugh Dickins wrote: > > + } else if (iter_is_iovec(to)) { > > + /* > > + * Copy to user tends to be so well optimized, but > > + * clear_user() not so much, that it is noticeably > > + * faster to copy the zero page instead of clearing. > > + */ > > + ret = copy_page_to_iter(ZERO_PAGE(0), offset, nr, to); > > Is the offset and length guaranteed to be less than PAGE_SIZE here? Almost :) The offset is guaranteed to be less than PAGE_SIZE here, and the length is guaranteed to be less than or equal to PAGE_SIZE - offset. > > Either way I'd rather do this optimization in iov_iter_zero rather > than hiding it in tmpfs. Let's see what others say. I think we would all prefer clear_user() to be enhanced, and hack around it neither here in tmpfs nor in iov_iter_zero(). But that careful work won't get done by magic, nor by me. And iov_iter_zero() has to deal with a wider range of possibilities, when pulling in cache lines of ZERO_PAGE(0) will be less advantageous, than in tmpfs doing a large dd - the case I'm aiming not to regress here (tmpfs has been copying ZERO_PAGE(0) like this for years). Hugh