Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp956139pxu; Mon, 23 Nov 2020 08:12:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJy+vfWqWcb4u6MBIRUH0/AVUguK7GXCcp72iBov/FfXUgZQfH0xrSGvdnaVkVn+1e7SJ7Zu X-Received: by 2002:a17:906:d790:: with SMTP id pj16mr304967ejb.125.1606147925460; Mon, 23 Nov 2020 08:12:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606147925; cv=none; d=google.com; s=arc-20160816; b=v7MTLww97v3Q0Ml83iYW9GeuBwx6rZVEzOavfVoGAHDs3WWrG5GY4kqZ/F8toMwxRp VzUMm7HM7Yx9L61PulW7LVf6bEtjFQnCzM3jzj0j/92wxA8NISe3RHhfZ6WMK45Mbw81 tDWdke+4OlFYMZJBdzM+xtJdJAsRJReA9GZTR6bd6iJXP98IvAUeqPIkZAoSFt1erp2X nWqAcFHStzOdVapOocyYwNLV+98Dhh8nAWSgdpy3OFwHefvGC7nFN5e2i6xW1Zj9jaPX daL866FxNwP/OQhFxuK7/nSISCE2v3UX4YTNfqtV3r9hmSOCL7qmLbN3c6U0mJH4UzQ1 XALw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=id/l05lUXRZXVoeT5E2V5g7f5O6E+dlvltH8HKfDmtQ=; b=oKr3IXeUjgSWyi7fRaVnw6Dq5H9w2SR1+o4DcXzTZTLitL7KYq6PnlXSg4G8S0I1mO ip0EvpJ45IRprwE1Z+pQ0H56bmKbQtrPhPUcrqNu6xGftPeJHxw/V3xXpdOJlhFxMPhB t5GhHwd9HM5fQ6tHDfVIKEGvcXyD7YgxFhFUa4u1J3SwQG0qVo1NBPC8neNydZO+4hbw BZjSKRqvW9esbcimjghrGYPlQkkLqTlTNdPjIgfBgp8YQvfm02zFbryHxI6+f10vR+St vJs/BNHjSCqgh3wJ0rQ7heIH9vct0ujTBTq/jmnnsQ1FpMzXxQU+gnMTm+HDwfFHgp4m t5zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=R9Cz4Sm0; 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 a15si7718609edr.228.2020.11.23.08.11.41; Mon, 23 Nov 2020 08:12:05 -0800 (PST) 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=@infradead.org header.s=merlin.20170209 header.b=R9Cz4Sm0; 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 S2389928AbgKWQIe (ORCPT + 99 others); Mon, 23 Nov 2020 11:08:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731032AbgKWQId (ORCPT ); Mon, 23 Nov 2020 11:08:33 -0500 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61367C0613CF for ; Mon, 23 Nov 2020 08:08:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=id/l05lUXRZXVoeT5E2V5g7f5O6E+dlvltH8HKfDmtQ=; b=R9Cz4Sm0LqXno5jNhdi2wuzuFe wpU4YHQTOPAaHjnyfWvgccWkR5bZIQ6Q3mHioTe3kDtaBt/9FWD/fi0QsLt6E2ANWwfcJK2VbnlFv ZzYnDU7cJWiLq99XkaMTtvpwLICLlMFeht9oxNtCuhTT75TAs/eL0KTRFJ4AgJW9nI/Bkt5Zp3HwQ sekTmartdABgp/vS68owgxY3JqtmG+Q9UahyU4cBwFmqFS8eVIHef6SB7qhRFOQWf+lg+my9N9d4n Ax/CJys262sHwABSJaVAvmG9GTNs15QUST/df6X7sDN+acTYRl67Il6YaOhgCuFACZaPMoQ1ZmRQn pQkWDBSg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1khEOA-0003Rv-8D; Mon, 23 Nov 2020 16:08:26 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 9CCF53070F9; Mon, 23 Nov 2020 17:08:23 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 81ACC20222D93; Mon, 23 Nov 2020 17:08:23 +0100 (CET) Date: Mon, 23 Nov 2020 17:08:23 +0100 From: Peter Zijlstra To: Marco Elver Cc: "Paul E. McKenney" , Will Deacon , Thomas Gleixner , Ingo Molnar , Mark Rutland , Boqun Feng , Dmitry Vyukov , kasan-dev , LKML Subject: Re: [PATCH v2] kcsan: Avoid scheduler recursion by using non-instrumented preempt_{disable,enable}() Message-ID: <20201123160823.GC2414@hirez.programming.kicks-ass.net> References: <20201123132300.1759342-1-elver@google.com> <20201123135512.GM3021@hirez.programming.kicks-ass.net> <20201123155746.GA2203226@elver.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201123155746.GA2203226@elver.google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 23, 2020 at 04:57:46PM +0100, Marco Elver wrote: > Let me know what you prefer. > > @@ -288,27 +288,19 @@ static u32 kcsan_prandom_u32_max(u32 ep_ro) > u32 res; > > /* > + * Avoid recursion with scheduler by disabling KCSAN because > + * preempt_enable_notrace() will still call into scheduler code. > */ > + kcsan_disable_current(); > preempt_disable_notrace(); > state = raw_cpu_ptr(&kcsan_rand_state); > res = prandom_u32_state(state); > + preempt_enable_notrace(); > + kcsan_enable_current_nowarn(); > > return (u32)(((u64) res * ep_ro) >> 32); > } This is much preferred over the other. The thing with _no_resched is that you can miss a preemption for an unbounded amount of time, which is bad. The _only_ valid use of _no_resched is when there's a call to schedule() right after it.