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 X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81455C433DB for ; Tue, 5 Jan 2021 09:20:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E8A2B20731 for ; Tue, 5 Jan 2021 09:20:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E8A2B20731 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 420988D0070; Tue, 5 Jan 2021 04:20:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3D16F8D006E; Tue, 5 Jan 2021 04:20:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E6C08D0070; Tue, 5 Jan 2021 04:20:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0219.hostedemail.com [216.40.44.219]) by kanga.kvack.org (Postfix) with ESMTP id 147868D006E for ; Tue, 5 Jan 2021 04:20:40 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id CA451181AEF09 for ; Tue, 5 Jan 2021 09:20:39 +0000 (UTC) X-FDA: 77671176198.10.fifth89_0b15652274d7 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id AAD1416A07E for ; Tue, 5 Jan 2021 09:20:39 +0000 (UTC) X-HE-Tag: fifth89_0b15652274d7 X-Filterd-Recvd-Size: 4059 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Tue, 5 Jan 2021 09:20:39 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1609838438; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LkWEVAne/Zp8rRQWRngkUvl4UBybdMI2J/82AEM+QYg=; b=Ow/Cqmex8Vu/mFIxqsr8sPRiLZJva5ws1xp7G4QywxnsDFYkOBWxL4goYV7K7MFPXGmSyv 0+Ek2ps4Oro+Niefyb9alahZ0/wm8ZTZ1xQX2nLuHri6RXqxgnMA7WznpkCvQ3KrU1Wd4l ge8iAJ1j6RxsdCW5Jq1YLrx0TTu8f0k= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 02FA6B720; Tue, 5 Jan 2021 09:20:38 +0000 (UTC) Date: Tue, 5 Jan 2021 10:20:37 +0100 From: Michal Hocko To: Dave Hansen Cc: David Hildenbrand , Matthew Wilcox , Alexander Duyck , Mel Gorman , Andrew Morton , Andrea Arcangeli , Dan Williams , "Michael S. Tsirkin" , Jason Wang , Liang Li , linux-mm@kvack.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: Re: [RFC v2 PATCH 4/4] mm: pre zero out free pages to speed up page allocation for __GFP_ZERO Message-ID: <20210105092037.GY13207@dhcp22.suse.cz> References: <43576DAD-8A3B-4691-8808-90C5FDCF03B7@redhat.com> <6bfcc500-7c11-f66a-26ea-e8b8bcc79e28@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <6bfcc500-7c11-f66a-26ea-e8b8bcc79e28@intel.com> Content-Transfer-Encoding: quoted-printable 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 Mon 04-01-21 15:00:31, Dave Hansen wrote: > On 1/4/21 12:11 PM, David Hildenbrand wrote: > >> Yeah, it certainly can't be the default, but it *is* useful for > >> thing where we know that there are no cache benefits to zeroing > >> close to where the memory is allocated. > >>=20 > >> The trick is opting into it somehow, either in a process or a VMA. > >>=20 > > The patch set is mostly trying to optimize starting a new process. So > > process/vma doesn=E2=80=98t really work. >=20 > Let's say you have a system-wide tunable that says: pre-zero pages and > keep 10GB of them around. Then, you opt-in a process to being allowed > to dip into that pool with a process-wide flag or an madvise() call. > You could even have the flag be inherited across execve() if you wanted > to have helper apps be able to set the policy and access the pool like > how numactl works. While possible, it sounds quite heavy weight to me. Page allocator would have to somehow maintain those pre-zeroed pages. This pool will also become a very scarce resource very soon because everybody just want to run faster. So this would open many more interesting questions. A global knob with all or nothing sounds like an easier to use and maintain solution to me. > Dan makes a very good point about using filesystems for this, though. > It wouldn't be rocket science to set up a special tmpfs mount just for > VM memory and pre-zero it from userspace. For qemu, you'd need to teac= h > the management layer to hand out zeroed files via mem-path=3D. Agreed. That would be an interesting option. > Heck, if > you taught MADV_FREE how to handle tmpfs, you could even pre-zero *and* > get the memory back quickly if those files ended up over-sized somehow. We can probably allow MADV_FREE on shmem but that would require an exclusively mapped page. Shared case is really tricky because of silent data corruption in uncoordinated userspace. --=20 Michal Hocko SUSE Labs