Received: by 10.223.185.116 with SMTP id b49csp1717147wrg; Thu, 22 Feb 2018 01:49:22 -0800 (PST) X-Google-Smtp-Source: AH8x226pL+rQ9nEDFMMqeQlFUGuxEX4WalxJaDl+vbHlsWdlYNGzQ+uAk2I9vuUZjstIPHaW/xgk X-Received: by 10.98.65.198 with SMTP id g67mr6292742pfd.127.1519292962644; Thu, 22 Feb 2018 01:49:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519292962; cv=none; d=google.com; s=arc-20160816; b=vDT840JYC5Q+Gxx7bqaI8sJXTEfy4taK0QWTyGCH3y+0izn6SZjxRFWWrpovrq5mjV XaQboLjG7cArsvy4vVTVdM8igqxcUTS81J0SHyNFVf2ml2qPedsRPiMnS1Is+V4JH5o+ lxa5fzXzsA5+HfCv31fgEvtuANA85Oi7eL2a1g/EvQCUGAvqoc2geHG7H0Kfym0jQ3Gv fvDTM+BG9otaqynAm9D+5VgfkRM/PlCMikg0KEzga41DtIQ1cEJcM64NcbmhOj3ZbL9B 3sirhV7UkbPsvzyfYLH9O6T2MJ98Smb8jlu3DQpmqwZiJqQDmCu4HEiYJIhFKOBgmO4D V+yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=WFJEJ+jJMEazbWtKYnhvW+CT9fUOMlH8ehaqnf/NCkM=; b=vAGzeHkhIQmNMBs5ZWhR9ZgS3JSduVT1zDAwUjGfOwJewiNGnVdKnahzvcGbI6d49j lZFlQ1V09LJYCm7mSSMNA1pYbq+rTlMwsxa5whNLjHWyrSMDGKZvJt0R1FzU3dHB/Rt+ z+IqdJyLSWF6iOXPbJj+YBeIgGaQ6VwD+26DxFAq+2ijJ2/NbeV0rqDyxUtrj0ar5kYm v4MIVBYj2GCgDr/PiHg0Q9GrZ1G4qwLetmggTkhN3oRAo0CuahJK3BG445yeVhrVqtoX IkWz/gfjvbTuUIfkqlXstjiHOz993g2tYKBYwSrmNiaW0JfFnVwWYVfoWdZ/az93fcbt bs4A== ARC-Authentication-Results: i=1; mx.google.com; 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 k128si2364322pgc.609.2018.02.22.01.49.07; Thu, 22 Feb 2018 01:49:22 -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; 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 S1753198AbeBVJsB (ORCPT + 99 others); Thu, 22 Feb 2018 04:48:01 -0500 Received: from outbound-smtp08.blacknight.com ([46.22.139.13]:55037 "EHLO outbound-smtp08.blacknight.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752961AbeBVJsA (ORCPT ); Thu, 22 Feb 2018 04:48:00 -0500 Received: from mail.blacknight.com (pemlinmail06.blacknight.ie [81.17.255.152]) by outbound-smtp08.blacknight.com (Postfix) with ESMTPS id 62ACD1C1ADB for ; Thu, 22 Feb 2018 09:47:59 +0000 (GMT) Received: (qmail 6099 invoked from network); 22 Feb 2018 09:47:59 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[37.228.237.61]) by 81.17.254.9 with ESMTPSA (DHE-RSA-AES256-SHA encrypted, authenticated); 22 Feb 2018 09:47:59 -0000 Date: Thu, 22 Feb 2018 09:47:58 +0000 From: Mel Gorman To: Andy Lutomirski Cc: Andrew Morton , Kees Cook , Jann Horn , Ingo Molnar , Laura Abbott , Thomas Gleixner , Al Viro , Sahara , "Levin, Alexander (Sasha Levin)" , Michal Hocko , Andrea Arcangeli , "Kirill A. Shutemov" , LKML , Kernel Hardening Subject: Re: [PATCH] fork: Allow stack to be wiped on fork Message-ID: <20180222094758.4qzvhoiu4hnmqkzq@techsingularity.net> References: <20180117055015.GA15256@beast> <20180220163142.15366a82a7bece715b997597@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170912 (1.9.0) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 21, 2018 at 01:56:33AM +0000, Andrew Lutomirski wrote: > > It would be much nicer to be able to control this at runtime rather > > than compile-time. Why not a /proc tunable? We could always use more > > of those ;) > > /proc/sys/kernel/hardening_features_that_cost_essentially_nothing? > > Seriously, though, why don't we just enable it unconditionally? It > wouldn't surprise me if it really is a speedup on more workloads than > it slows down -- it'll fill the kernel stack into the CPU cache with > exclusive ownership very quickly (streamily and without actually > reading from memory, I imagine, at least on new enough CPUs) rather > than grabbing each cache line one by one as they get used. Note that this is not unconditionally true, it depends on the calling context that clears the page. If this is during fork, then the parent may be doing the clear (I didn't check) which means it's quite likely when the child wakes for the first time that it will not necessary wake on the same CPU. Up until recently on NUMA machines, the child was almost guaranteed to be running on a remote node (mitigated in tip for sched now). I'm not claiming I've measured the overhead of this, just pointing out that "cache hotness" may actually result in double the cache line bounces -- first clear, then write on first wake. If only zeroing pages was a bit faster :/ -- Mel Gorman SUSE Labs