Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5694445rwl; Tue, 4 Apr 2023 02:08:43 -0700 (PDT) X-Google-Smtp-Source: AKy350Y2HdbQ4iBPtM53AgjbCXslJXpd/UU2JhN5mYHdBU+6JfO4GPhEna8rC/9SJGlnFP+dupAZ X-Received: by 2002:a17:902:c9cc:b0:1a1:b3bb:cd5b with SMTP id q12-20020a170902c9cc00b001a1b3bbcd5bmr1796802pld.62.1680599323648; Tue, 04 Apr 2023 02:08:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680599323; cv=none; d=google.com; s=arc-20160816; b=xOD3vMvpRSThaWweAn20J7IhcEhV3IHmrVYSO7GTWM5E7cGmR3zEoVJXEJuQFEAvWp 2o1JzgUbMcjj82006OAKYjlFVwMKjqnhquPkXF1uQvp9bgkQ5tP69l6Bo+Iv+5T7+TwL odCYV9Rurpsq++59/AeHsKbkvN+39E2s5fwPYbPKdEYlU6TwqVindO4ihV4ScpiSU7Cm +YfjjZxgTyrND5uGUJICbn8WxSDw+Te8tdDmispyqpwjUaCphNHB8jisdDbY4hO3g6Rn Kz346mcVzVpN1LRYdhG0EiIifGtJ9OpNo1RVSiDBhiv7k6D8+TJM0GfrjYrdA9hawRYx ZVdQ== 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=72ruK2mNbys8PIyy35QTUdR95rFv5PixX6W/SrUuWJw=; b=f0y/qcViFBj6boxi1OXAJcb6Xlha02UMq7XTDZiaEKUmbn+gnMl3CwrzZMOQ5TD7k6 W8kRoAdNOWf2yzSHHZ/MU9u4PeTiIQh+qmMdDvptI8iosSzMduKfqliEiALHjBL/Oskm mr4Vc7mwQY67huSEw88r8S+E2qmvnseQbxv2aU4YqK5b61mO8B6HZJyq2Lqqt3ZgJLpR EyN7xAC+J7HLnrbL+mRuM2Id6rm9RXjQpsOSbM/VdqHFHc5PeuDxD2gV2E3ASZccx+Uv 6K4DXbzbEG4LhVZhsrv1NH5YI7zGUWJHRmQ/lpXw+wcMtNIalY2ZnFTKeeEYL2JsVdo6 HzYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=DURlYlue; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s2-20020a170902b18200b001960922af15si9543719plr.239.2023.04.04.02.08.31; Tue, 04 Apr 2023 02:08:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=DURlYlue; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234044AbjDDJFO (ORCPT + 99 others); Tue, 4 Apr 2023 05:05:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232063AbjDDJFM (ORCPT ); Tue, 4 Apr 2023 05:05:12 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAF1AE62 for ; Tue, 4 Apr 2023 02:05:11 -0700 (PDT) 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=72ruK2mNbys8PIyy35QTUdR95rFv5PixX6W/SrUuWJw=; b=DURlYlueYIkrRxJcf9zNnwLPPg PPHqKqMRKMJNRVr/xAtnalqVCbDOY/16XfC6V780xTynhn2ccs45RDjg6lCqOY2Ln7EA1/RYMB7Gn x6iMnMnZcS9L/2R0EYml0+4LnLW3t/Iio/7fzFqoW9ZHebfLCu5TBlPUT14zuUqyNsXgeKweyk2Yh t+if8w4iOu4gyZLO170sw9xfXg6FhbJY0RoQeD63P54RVMtfPbzfzpjvRkgu92LLbwkvBHXTo7Yvm mQPJHLHuFOOIMeTEGwHpxDlaSwYm+05PwZE7TNO/SnwnX03x1HUP3mkK+p1T/Vcov6Xs3PP4qI6Ej cAIxEvhQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pjcbD-00FD8a-VI; Tue, 04 Apr 2023 09:05:08 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 8881530003A; Tue, 4 Apr 2023 11:05:07 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 711252B6E1F53; Tue, 4 Apr 2023 11:05:07 +0200 (CEST) Date: Tue, 4 Apr 2023 11:05:07 +0200 From: Peter Zijlstra To: Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, Aaron Lu Subject: Re: [RFC PATCH] sched: Fix performance regression introduced by mm_cid Message-ID: <20230404090507.GB284733@hirez.programming.kicks-ass.net> References: <20230403181342.210896-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230403181342.210896-1-mathieu.desnoyers@efficios.com> X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 03, 2023 at 02:13:42PM -0400, Mathieu Desnoyers wrote: > void sched_mm_cid_exit_signals(struct task_struct *t) > { > struct mm_struct *mm = t->mm; > - unsigned long flags; > + struct rq_flags rf; > + struct rq *rq; > > if (!mm) > return; > - local_irq_save(flags); > + > + preempt_disable(); > + rq = this_rq(); > + rq_lock_irqsave(rq, &rf); > mm_cid_put(mm, t->mm_cid); > - t->mm_cid = -1; > + t->last_mm_cid = t->mm_cid = -1; > t->mm_cid_active = 0; > - local_irq_restore(flags); > + rq_unlock_irqrestore(rq, &rf); > + preempt_enable(); > } FWIW a *slightly* cheaper form is: preempt_disable(); rq = this_rq(); rq_lock_irqsave(rq, &rf); preempt_enable_noresched(); /* holding spinlock */ ... rq_unlock_irqrestore(rq, &rf);