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 8B6F9C2D0E4 for ; Thu, 19 Nov 2020 11:51:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 750FF246CA for ; Thu, 19 Nov 2020 11:51:48 +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="c075Zv/r" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 750FF246CA 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 66AF86B005D; Thu, 19 Nov 2020 06:51:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 61B5F6B0068; Thu, 19 Nov 2020 06:51:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 50A446B006C; Thu, 19 Nov 2020 06:51:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0238.hostedemail.com [216.40.44.238]) by kanga.kvack.org (Postfix) with ESMTP id 242FE6B005D for ; Thu, 19 Nov 2020 06:51:47 -0500 (EST) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B3BB28249980 for ; Thu, 19 Nov 2020 11:51:46 +0000 (UTC) X-FDA: 77501003412.13.oil16_3506fe027342 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id 9210618140B67 for ; Thu, 19 Nov 2020 11:51:46 +0000 (UTC) X-HE-Tag: oil16_3506fe027342 X-Filterd-Recvd-Size: 4268 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Thu, 19 Nov 2020 11:51:44 +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=dY3xCz1US42IgUQKvQZydem55nNev0dCCyUsmh22YNA=; b=c075Zv/rt9hDk0DBiY3b9jGPqB mzkAi0MZcNSlkjxpMVH3kpo8s4csl9dZJvktJ5dvdqHJ/QY7UoroqjdUMkSXnNSxm4QB13j8dsSdT y/LlYYLB0MrH2mIuEVH8zpzhkK67Ec23tDdlu/SANoxS/ZywxjZpt3mmP0ZHGySU2my8Pq31qkJLU EQfuucPWrjF10uaiLJhqKT3PJTAOlGGVIuf8S18TVQv/qshjwJ6qeiSgimLQtFPGC7CRnwdERpLTr 1+i74V5qMpMUtJ6MKXBzMUF53e1uqhGuoZsyNpHnse7W4Oh/CfKTp3zzySvn57K48jRnEYnkPusii V5Q5Xj0Q==; 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 1kfiTO-00015A-52; Thu, 19 Nov 2020 11:51:34 +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 92B833060AE; Thu, 19 Nov 2020 12:51:32 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 5A56820126362; Thu, 19 Nov 2020 12:51:32 +0100 (CET) Date: Thu, 19 Nov 2020 12:51:32 +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: <20201119115132.GN3121378@hirez.programming.kicks-ass.net> References: <20201118194838.753436396@linutronix.de> <20201118204007.372935758@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201118204007.372935758@linutronix.de> 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 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?