Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp30422ybz; Thu, 23 Apr 2020 17:38:57 -0700 (PDT) X-Google-Smtp-Source: APiQypJ5ou+4ZTN+ffrqXWex4PAloLcB1wZWozdvqVr4TSelAQb4swA2PECTQxKBAfh8CpJ4mMPg X-Received: by 2002:aa7:d413:: with SMTP id z19mr5260984edq.80.1587688737598; Thu, 23 Apr 2020 17:38:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587688737; cv=none; d=google.com; s=arc-20160816; b=pWr2W44h5+HViF1hRNBo816cGmZaOp37ogu15kCYdRT8APfahy4bkikUSRqEAFXrR/ xpJdYav3WzKpYu5QKH0dHW5VQ8xXlUY9pJk1Zzva6Ziv64IhIi2bFqcIdWP8/eeKy+Eh XnJi/f6epSEEXu4T+gCvXYFuDRnLZSSDMA+Ao840PC5KvDcO7IQ+9lszRjAnzAxxL+JE lh0frh1iCn0yAVei0cGK33WHX6tbtFH1VSZjj8lFaPTDBOQvmY9MEJIGa0Tl2U6/fA7c l/G8HiKrvl/3klLvsD6DHTfxNc3jroYLgrgOVeM5JP3KX+dZtq3nHUJK2x0Enzq7zKMX 0cRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=ZLWzoa/VYHCxT5f70or87lDKVmk+wC9dJGvog3l+rZw=; b=UNIsYL2F25792cTc5D6b7eGlDgbNOJLnit86umqbSTRFGp9tqrihJxd2UIzx6F8aBD Zwe8xoKsK2Ayaz1K0IWhwBS2moMaWfkkGIgPrd4bfpL+7ktdOBjmDTvh2bOYQ/tn6txQ Ig1ubAkKl3g6nfbKWgTCq1Tlx/pXXWdABusUuAgA3kgzxDebGfH0EcAC0fGHbMaFS+Gb UU3Jeld5BydW7ombol/NWDN0I4xV6ai2kcep9lZETqwWdwEt7k9IB96SiqzyT8LEfOCD OLtPXPAaxIosNi1xMvUzHCwaUucgCf7jv9v26Rx6jJjoUv0Oe62fj2ruLeTZxD7MjhAn ev/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mCcuVeIx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i7si2120152eja.355.2020.04.23.17.38.33; Thu, 23 Apr 2020 17:38:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mCcuVeIx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728250AbgDXAhC (ORCPT + 99 others); Thu, 23 Apr 2020 20:37:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:53578 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728151AbgDXAhC (ORCPT ); Thu, 23 Apr 2020 20:37:02 -0400 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1AB9F20724; Fri, 24 Apr 2020 00:37:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587688621; bh=tC2001WkgCBwNlCeRGsPzZqCfwtG295aimilTWbtkPk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=mCcuVeIxrvSePAS4k6nimdfYFtNup9/RbCL8uQOKtsUv1PIhP3zQ420IcUVF4qPOZ hw+2Pte9WnQGQLDmBjLhybNgT1iYhcX0MiyH/qnxsrbvvvCaR3OyF9Gjs4DTYb0NOZ 9LMi8hZsa+qoYSJYWwj5+mK1ys6TNdGkeYA8GXFQ= Date: Thu, 23 Apr 2020 17:37:00 -0700 From: Andrew Morton To: Vlastimil Babka Cc: Alexander Duyck , Matthew Wilcox , Mel Gorman , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrea Arcangeli , Dan Williams , Dave Hansen , David Hildenbrand , Michal Hocko , Alex Williamson Subject: Re: [RFC PATCH 4/4] mm: Add PG_zero support Message-Id: <20200423173700.b2c954b3960e4379a4f82e80@linux-foundation.org> In-Reply-To: <344a3a78-62ad-48fe-40cf-18993175d1e0@suse.cz> References: <20200412090945.GA19582@open-light-1.localdomain> <20200412101223.GK21484@bombadil.infradead.org> <5eb37d79-6420-fcb9-2b4c-6cc6194afcd9@linux.intel.com> <20200413140537.eb674579cf8c71b4e20581ab@linux-foundation.org> <344a3a78-62ad-48fe-40cf-18993175d1e0@suse.cz> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 22 Apr 2020 16:09:00 +0200 Vlastimil Babka wrote: > On 4/13/20 11:05 PM, Andrew Morton wrote: > > On Mon, 13 Apr 2020 08:11:59 -0700 Alexander Duyck wrote: > > > >> In addition, unlike madvising the page away there is a pretty > >> significant performance penalty for having to clear the page a second > >> time when the page is split or merged. > > > > I wonder if there might be an issue with increased memory traffic (and > > increased energy consumption, etc). If a page is zeroed immediately > > before getting data written into it (eg, plain old file write(), > > anonymous pagefault) then we can expect that those 4096 zeroes will be > > in CPU cache and mostly not written back. But if that page was zeroed > > a "long" time ago, the caches will probably have been written back. > > Net result: we go from 4k of memory traffic for a 4k page up to 8k of > > memory traffic? > > Heh, I was quite sure that this is not the first time background zeroing is > proposed, so I went to google for it... and found that one BSD kernel actually > removed this functionality in 2016 [1] and this was one of the reasons. > > [1] > https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/afd2da4dc9056ea79cdf15e8a9386a3d3998f33e Interesting. However this: - Pre-zeroing a page leads to a cold-cache case on-use, forcing the fault source (e.g. a userland program) to actually get the data from main memory in its likely immediate use of the faulted page, reducing performance. implies that BSD was zeroing with non-temporal stores which bypass the CPU cache. And which presumably invalidate any part of the target memory which was already in cache. We wouldn't do it that way so perhaps the results would differ.