Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp143754pxx; Wed, 28 Oct 2020 00:30:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxa/oczhCvTcjXrTqzLNCdHceASCYI0KOvYeOWQM9NzVdGFnWyuOPJkWcV+uGaczpR2BGAZ X-Received: by 2002:aa7:dc42:: with SMTP id g2mr6411914edu.11.1603870248671; Wed, 28 Oct 2020 00:30:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603870248; cv=none; d=google.com; s=arc-20160816; b=yhbfx0A3uw2qIcVvTRHNbdNKHYEHj6jvrejs59dKyQ9D5jaqVs9rTufg8nS3/NAh9e 6JxNY7/a+ystlZfzEi1+M5DhU5zASYXyC2wmwTzsAhdjLJ2heKVRun9frlnmyc5xoRdV 1LdgF73Nj2NQBdSoIzdmYFCYBO7MdZpkF+z6e90DA7iDc24TxwrgjbUWQ3QwDKU2Wzrv S3Y9mXEBbekhFqa4btz+cMHOJ1MpyiHEK1ftcDOO58uBOqWm8e5z8OzwYRG/Umkefbi7 CBAz46JEjGchDdCu2EuMh7SEK+YizD7/t6lhdT26ACoPQZHTFkBv/ql5BbDO39iOUCZM opuA== 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=XTAQQlA0WbRz5jiSk+bpjBrWCi9CcQ1Kg+3G/82T1os=; b=whfUqvZCPvpXk+QB1mGudTzbTQ8Lwv2vTIHfwtZF3W+xHKRRw33GJKBggKwY93Y3P7 tom/v+YO5L7kvX5LyMK8swGNSnIDiXgZJSkeBC4OiPEK1nTJ87wIHMK2oqST707/dXsb wRsqRT0GVs2Eeb6kj5MuUFP1r021MYgDFWs/FXwzjjdYhBnive2g7KsVVauo1YL7SqX4 aJyqKVS2mBeEtg2iKD/xGPWKhaBz3iv1BKMAaKaWSA6KwiMotUvxWkpL8Qz31bi+XUxQ nKeAexr/BYl7Dx29kSvn3jAxUempLevyTU2g1VncvRoOOYpaaxuj7wseJLa5UaCTX8J2 bbUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="PAZCCQ/7"; 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 gj23si3047864ejb.600.2020.10.28.00.30.26; Wed, 28 Oct 2020 00:30:48 -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=@infradead.org header.s=casper.20170209 header.b="PAZCCQ/7"; 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 S2899831AbgJ0M2t (ORCPT + 99 others); Tue, 27 Oct 2020 08:28:49 -0400 Received: from casper.infradead.org ([90.155.50.34]:39922 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2899714AbgJ0M2s (ORCPT ); Tue, 27 Oct 2020 08:28:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=XTAQQlA0WbRz5jiSk+bpjBrWCi9CcQ1Kg+3G/82T1os=; b=PAZCCQ/7JM0U/OQgGDz25uELuv 4XQkVFPCCaNOP5+kr4ZTu4QrBAhbCu9e/aSKbES9FQtiPU2KGRCKUFBdtZ71ll6ilmzhk6ux8xT1K 3PT/G5v9oiGSXobrbv1grQ2hTUhve+l0EzAICSi9kZV9iZhLjlWit228+laN8xWODFmh/BMz5NPEE jKwmt23aVQa6EUH5l53N6ZjMewu/iZQp6KaiSmstA85nTNqFyFZkvq+qmz3CUtWrzrUEQFgvEVdAw DknLn/+2/Oc0x7/tw4QKndPSL3yuNEnWGxkl8Uf9IMDBZmXuy960/8XY0UmcLhR7h61CBBpoQHTDm wDp7UExw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXO5h-0000nK-JJ; Tue, 27 Oct 2020 12:28:42 +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 2760B3006D0; Tue, 27 Oct 2020 13:28:41 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 13F6F2B851A29; Tue, 27 Oct 2020 13:28:41 +0100 (CET) Date: Tue, 27 Oct 2020 13:28:41 +0100 From: Peter Zijlstra To: Frederic Weisbecker Cc: Michal Hocko , Thomas Gleixner , Mel Gorman , Frederic Weisbecker , Ingo Molnar , LKML , x86@kernel.org, Linus Torvalds , Josh Poimboeuf Subject: Re: [RFC PATCH v2 0/5] allow overriding default preempt mode from command line Message-ID: <20201027122841.GK2628@hirez.programming.kicks-ass.net> References: <20201009122926.29962-1-mhocko@kernel.org> <20201009174554.GS2611@hirez.programming.kicks-ass.net> <20201027122241.GA140902@lothringen> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201027122241.GA140902@lothringen> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 27, 2020 at 01:22:41PM +0100, Frederic Weisbecker wrote: > On Fri, Oct 09, 2020 at 07:45:54PM +0200, Peter Zijlstra wrote: > > +DEFINE_STATIC_KEY_TRUE(irq_preemption_key); > > + > > +/* > > + * SC:cond_resched > > + * SC:might_resched > > + * SC:preempt_schedule > > + * SC:preempt_schedule_notrace > > + * SB:irq_preemption_key > > + * > > + * > > + * ZERO > > + * cond_resched <- RET0 > > + * might_resched <- NOP > > + * preempt_schedule <- NOP > > + * preempt_schedule_notrace <- NOP > > + * irq_preemption_key <- false > > + * > > + * NONE: > > + * cond_resched <- __cond_resched > > + * might_resched <- NOP > > + * preempt_schedule <- NOP > > + * preempt_schedule_notrace <- NOP > > + * irq_preemption_key <- false > > + * > > + * VOLUNTARY: > > + * cond_resched <- __cond_resched > > + * might_resched <- __might_resched > > + * preempt_schedule <- NOP > > + * preempt_schedule_notrace <- NOP > > + * irq_preemption_key <- false > > + * > > + * FULL: > > + * cond_resched <- RET0 > > + * might_resched <- NOP > > + * preempt_schedule <- preempt_schedule > > + * preempt_schedule_notrace <- preempt_schedule_notrace > > + * irq_preemption_key <- true > > + */ > > That's cute! I'll try to end up to that result. Beware, ZERO is 'broken', I included it because I was curious what, if anything, would happen :-) > > +static int __init setup_preempt_mode(char *str) > > +{ > > + if (!strcmp(str, "zero")) { > > + static_call_update(cond_resched, __static_call_return0); > > + static_call_update(might_resched, (void (*)(void))NULL); > > + static_call_update(preempt_schedule, (void (*)(void))NULL); > > + static_call_update(preempt_schedule_notrace, (void (*)(void))NULL); > > + static_branch_disable(&irq_preemption_key); > > + printk("XXX PREEMPT: %s\n", str); > > + } else if (!strcmp(str, "none")) { > > + static_call_update(cond_resched, __cond_resched); > > + static_call_update(might_resched, (void (*)(void))NULL); > > + static_call_update(preempt_schedule, (void (*)(void))NULL); > > + static_call_update(preempt_schedule_notrace, (void (*)(void))NULL); > > + static_branch_disable(&irq_preemption_key); > > + printk("XXX PREEMPT: %s\n", str); > > + } else if (!strcmp(str, "voluntary")) { > > + static_call_update(cond_resched, __cond_resched); > > + static_call_update(might_resched, __might_resched); > > + static_call_update(preempt_schedule, (void (*)(void))NULL); > > + static_call_update(preempt_schedule_notrace, (void (*)(void))NULL); > > + static_branch_disable(&irq_preemption_key); > > + printk("XXX PREEMPT: %s\n", str); > > + } else if (!strcmp(str, "ponies")) { > > + static_call_update(cond_resched, __cond_resched); > > + static_call_update(might_resched, (void (*)(void))NULL); > > + static_call_update(preempt_schedule, preempt_schedule_thunk); > > + static_call_update(preempt_schedule_notrace, preempt_schedule_notrace_thunk); > > + static_branch_enable(&irq_preemption_key); > > + printk("XXX PREEMPT: %s\n", str); > > Why would we need that ponies version? We don't, but it was a missing combination (like ZERO), and I wanted to test it worked (as expected, it does). We'll only encounter it as an intermediate state when flipping states at runtime, but unlike zero, it should work just fine.