Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5997610rwl; Tue, 4 Apr 2023 06:37:24 -0700 (PDT) X-Google-Smtp-Source: AKy350ZzSDskUC0PZCeNDQBUHDSjJ5GD7F2Bu+2Jf9TfwgpQR4pXQFY+DAD8kkhKMhU4Wn0JsiIb X-Received: by 2002:a17:903:22c4:b0:19c:b7da:fbdf with SMTP id y4-20020a17090322c400b0019cb7dafbdfmr3748397plg.26.1680615443846; Tue, 04 Apr 2023 06:37:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680615443; cv=none; d=google.com; s=arc-20160816; b=h7DEvCaAg9PO38eHOaFNR0hx7N6V+bOcLEC0b0+uFJqoPNa+8E9QDdjXt0qj1FkGgT 2vEmfjZH7DNBbJQ4UwzLNpMJIIpOJ03QwhLgatbxsBseQByEeB4e36XzurHl0FhP0AL3 YNA5Tv3Wx89G+QetedFqvlD/C7TtL2n+MPJLPmSYylsGBX79Kj0zmNhX1t/pv4+k7Sga DemXMg84FJB9J+uqWsPxYbQW572gdxD/VgehYEeQpBSi87s0ztIp1Qlt5HUy+IjgU5T1 6CvZDx7YqMi6sLP+IGOgoriFikN2IQKRlcNtyBaYnzuzvFgRvDox1owqO8caUDTtAOJR xvEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=krfdyhGnTXJ1sJrSee9KVHtLzXcBwUAv4c+9soNHKas=; b=AUQXRoki04zO1kRGx6bDuO7uac06lRO+kvoWLatSqg8Yh5FHfBv1xSRozIS6x5RtKB qS092OL5BV7JbGJC9p3tXGJgKFcRe9F5OrfZYSXJ5i26Us7ns84r1ld4SONC0GbGMJQp 2N6S7nbjUsdx47thuKlpzgUIb2Fvzt8NFuB+t0fIpa+8zEGKjoc8A0L2X3Y2rSvIh+Gr ROf8ABvOFMeRWoA1CQranIAISCRTNpWzk8SGKW/KFW1MvCvJPrEzT+d2TdIE38hmkuDG CLCJE6ga02QQD4BzMlQ++ly/GwbJvqVn/9/Fdu4vMbVwlciegiOs2bGJS7+3grz+L0I4 y8sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=PcmjDr4T; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lf5-20020a170902fb4500b001992f451a28si9848546plb.384.2023.04.04.06.37.11; Tue, 04 Apr 2023 06:37:23 -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=@efficios.com header.s=smtpout1 header.b=PcmjDr4T; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234830AbjDDNgP (ORCPT + 99 others); Tue, 4 Apr 2023 09:36:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235116AbjDDNgM (ORCPT ); Tue, 4 Apr 2023 09:36:12 -0400 Received: from smtpout.efficios.com (unknown [IPv6:2607:5300:203:b2ee::31e5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A46484C2E for ; Tue, 4 Apr 2023 06:35:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1680615345; bh=Q3zzaU8OJ7SujJ7Qn+zJDO63bhmu4n16qzbZQvS9wT4=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=PcmjDr4TDP+X32BhXg5EpCw7Akhx+fw+B3oLeKPIaN+2rN7RGznx0vUVxmU01dhyz /skLlqy1pt4+uLfZOFX/DZxyjkg3lgLe5s6oGRMbor/py9BZb540UGpMY7jPc7NnoH MJZivfYemdMLoLrTgDVy3zATGCzkS6X1HYSwhT6ejUj6yjGNSzaQpvANdFUFZbiRaX mUU1z+ueEDkyDth0Md3CDAARy1Thl9TN3jn/UEbh+L2xDAO8JGRCRXQUc7x5NFEEJU Y27RBL1ZscN9SDdE7eHRO018a4ji/OU+BRC4pNr1dyf8c2+NzQJxmOuHa40bqvR4NL RZTmv8amTkxQg== Received: from [172.16.0.188] (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4PrTKs2LvRztx9; Tue, 4 Apr 2023 09:35:45 -0400 (EDT) Message-ID: Date: Tue, 4 Apr 2023 09:24:54 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [RFC PATCH] sched: Fix performance regression introduced by mm_cid Content-Language: en-US To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, Aaron Lu References: <20230403181342.210896-1-mathieu.desnoyers@efficios.com> <20230404090507.GB284733@hirez.programming.kicks-ass.net> From: Mathieu Desnoyers In-Reply-To: <20230404090507.GB284733@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, SPF_PASS 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 2023-04-04 05:05, Peter Zijlstra wrote: > 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); Good point, updated for next round. Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com