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=-8.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 BE331C2D0E4 for ; Thu, 19 Nov 2020 12:12:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B3554246B0 for ; Thu, 19 Nov 2020 12:12:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="sWVv8WMZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B3554246B0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 254456B0068; Thu, 19 Nov 2020 07:12:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2064F6B006E; Thu, 19 Nov 2020 07:12:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0CD596B0070; Thu, 19 Nov 2020 07:12:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0165.hostedemail.com [216.40.44.165]) by kanga.kvack.org (Postfix) with ESMTP id D324A6B0068 for ; Thu, 19 Nov 2020 07:12:13 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 71453180AD801 for ; Thu, 19 Nov 2020 12:12:13 +0000 (UTC) X-FDA: 77501054946.07.wave44_140a25627342 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id 520211808EE31 for ; Thu, 19 Nov 2020 12:12:13 +0000 (UTC) X-HE-Tag: wave44_140a25627342 X-Filterd-Recvd-Size: 4728 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Thu, 19 Nov 2020 12:12:12 +0000 (UTC) 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=l3xEnAx4q8O0EP6AAD5sJP833p89scGo7JAtlQmqAnM=; b=sWVv8WMZgyy6TyKuaeo5wkfASG Q25ZE2SOW/e9952expcHVgWvFp0TgKBiz3YJIwgmsW1vdtynDYk0HY2FaMlN1X0k+a4NttdR+SVrk X53X+Iw+NF0AcWtvAUH492STL35zM4HXfHg2PJ++A+yXmLTUGWRGoT5tlVbT+JXHAWieIUSenrL72 mP839E/mJJ/b/KHeeAcqzjG1m//HTx54i9l/QwUSS0ldDexD3kdcYPECxpkJage+sWSWhowFa8TTE 1f8teRtm4q47way9aJ1g+eOqBnG7szbh3Ti5OR/lGa+m6L1ZJL3TlYxf1q+bBqvRdCOgGZf50nNP1 5mRXf/AQ==; 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 1kfinC-0003Ro-Mz; Thu, 19 Nov 2020 12:12:03 +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 32AEA306BCA; Thu, 19 Nov 2020 13:12:01 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id F3BB120126362; Thu, 19 Nov 2020 13:12:00 +0100 (CET) Date: Thu, 19 Nov 2020 13:12:00 +0100 From: Peter Zijlstra To: Thomas Gleixner Cc: LKML , x86@kernel.org, Linus Torvalds , Christoph Hellwig , Matthew Wilcox , Daniel Vetter , Andrew Morton , linux-mm@kvack.org, Linus Torvalds , Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira Subject: Re: [patch V4 5/8] sched: highmem: Store local kmaps in task struct Message-ID: <20201119121200.GG3121429@hirez.programming.kicks-ass.net> References: <20201118194838.753436396@linutronix.de> <20201118204007.372935758@linutronix.de> <20201119115132.GN3121378@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201119115132.GN3121378@hirez.programming.kicks-ass.net> 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 Thu, Nov 19, 2020 at 12:51:32PM +0100, Peter Zijlstra wrote: > On Wed, Nov 18, 2020 at 08:48:43PM +0100, Thomas Gleixner wrote: > > > @@ -4073,6 +4089,7 @@ prepare_task_switch(struct rq *rq, struc > > perf_event_task_sched_out(prev, next); > > rseq_preempt(prev); > > fire_sched_out_preempt_notifiers(prev, next); > > + kmap_local_sched_out(); > > prepare_task(next); > > prepare_arch_switch(next); > > } > > @@ -4139,6 +4156,7 @@ static struct rq *finish_task_switch(str > > finish_lock_switch(rq); > > finish_arch_post_lock_switch(); > > kcov_finish_switch(current); > > + kmap_local_sched_in(); > > > > fire_sched_in_preempt_notifiers(current); > > /* > > > +void __kmap_local_sched_out(void) > > +{ > > + struct task_struct *tsk = current; > > + pte_t *kmap_pte = kmap_get_pte(); > > + int i; > > + > > + /* Clear kmaps */ > > + for (i = 0; i < tsk->kmap_ctrl.idx; i++) { > > + } > > +} > > + > > +void __kmap_local_sched_in(void) > > +{ > > + struct task_struct *tsk = current; > > + pte_t *kmap_pte = kmap_get_pte(); > > + int i; > > + > > + /* Restore kmaps */ > > + for (i = 0; i < tsk->kmap_ctrl.idx; i++) { > > + } > > +} > > So even in the optimal case, this adds an unconditional load of > tsk->kmap_ctrl.idx to schedule() (2 misses, one pre and one post). > > Munging preempt-notifiers behind a static_branch, which in that same > optimal case, avoided touching curr->preempt_notifier, resulted in a > measurable performance improvement. See commit: > > 1cde2930e154 ("sched/preempt: Add static_key() to preempt_notifiers") > > Can we fudge some state in a cacheline we're already touching to avoid > this? The only state we seem to consistently look at after schedule() is need_resched()'s TIF_NEED_RESCHED. But adding a TIF_flag to all archs and setting/clearing it from kmap_local might be a bit daft.. :/