Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp698640rwb; Thu, 8 Dec 2022 01:36:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf5jCHVEGC/9ay7IrvwlwS2aGemWtKWdHBla8AHS4xvSikFcsWDqBgJlMCU5vcsVO5ElUlWd X-Received: by 2002:a05:6402:230f:b0:46c:dc40:4635 with SMTP id l15-20020a056402230f00b0046cdc404635mr12102781eda.358.1670492182778; Thu, 08 Dec 2022 01:36:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670492182; cv=none; d=google.com; s=arc-20160816; b=x/Uts/PrUu7VCqfnd9b9FZZbZwmGb39KfBNMfIcc/i64XsiLEGay2TreCwxRX04Iu5 qitk4nt9OpamGJz84OfKi1EadHeyv6Mrv+ON+pRbHQkq6T0ow1pXCstxD9Txgw8ClyXi mN33gci3BmiFRpOVRv7CVm2oX+H0Dd7xSsZVc3847ltLkhogLFD2Hto8rg6YeV39EPz4 ahlz6cDobsqioGL5XRKpMTVPDrxeTtrIwfxD02yojLCSShozTSyIYvbOKMFurRDhygW2 WY9aVSDepF2ZuOYOcQ7xuamTEeFZmc1vlq5aYaTTnLonJ0+akkuqFLEDbp94J5FZljYT BPTA== 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 :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=JAAXRXPDf8By1YBPFI9GoJQjrKKS1JFL4TS12ITW2AA=; b=aCIg/tBU1N2wa1vIniwiVslpDThRtLn3WGwxBCK+XCBMLFsDDc8dTSww4oGscCcfkb mPQixZbrad/hHp84XpBnyqUvMT4RP697TAgRzrZW2k9YP4a4kQ1BuIjkPVslbFATWC+i qbnro8KocCS+Vu7fTliWxxlNG8NC5cYTxdB1XcLzJAf2GA5ui/qhtO/7ur4EZcKVeSa8 XbdKWhKyT0DVR9RjyfpHb6RCQpgWSmcHqlI0e5ugrPk+VymCVnQO4r63dLOMBPUWRno6 q4mVwusRum/RitEYB2bP0mhtJO4x7/Fyxdt0l6ULiYJeyjsSBvawWNEB162gMpfaKpq4 jacA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=L2aZ681V; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c1-20020a056402100100b0046aee4c4eb3si5373999edu.26.2022.12.08.01.36.04; Thu, 08 Dec 2022 01:36:22 -0800 (PST) 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=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=L2aZ681V; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230135AbiLHJIt (ORCPT + 72 others); Thu, 8 Dec 2022 04:08:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230075AbiLHJIN (ORCPT ); Thu, 8 Dec 2022 04:08:13 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CEB74B775 for ; Thu, 8 Dec 2022 01:07:58 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id w4-20020a17090ac98400b002186f5d7a4cso4037346pjt.0 for ; Thu, 08 Dec 2022 01:07:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=JAAXRXPDf8By1YBPFI9GoJQjrKKS1JFL4TS12ITW2AA=; b=L2aZ681VQn0PT/5g4s+wvARgOx7f69+jSd9jFqblkrKTpSc6ASwygnzE1TpNCW4jEd a0alh9tWpcWx9x83KWAAxkftHfzQv2p8ggpRJZKI/nnStWMj2muCaAa3lTL2Wibx4a1L PKmX0djGN/IWzPWiMnNdtc5wD6w5Rl8RK+uG4F0FB5splcZwj2STOehPRQmvWUDmBoGF WLk+1O+FHTFyu7RWcUrart1iPs1VwxZr9MAMN4U5T5IGxKdYaDmvz1urxm8U48JbawDK u/Hr1FxsUc6EITZkU+OG2IBh9oYIUxk78bvuPQMmAad60nCzoxEFA5dBHbRQTkKnIzW/ WfSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=JAAXRXPDf8By1YBPFI9GoJQjrKKS1JFL4TS12ITW2AA=; b=3NO4avuxH936mwxxWNPfn0A6hn9sF842T1oI0gp1n6Td3U9sk/2zlquyP5H74AQwSF pr2AV7wfnTOjuGHggXBqRZEXjZn3Gd/rV2YjiPnYMxoI3sge72hmpK4qI41oP/PWRxSQ na6cJ/vmxYekUqYptL6EWY1bS5snm5RAjt0dfIU7Uod2LpPRnXhUCNF2m741CHalAW8P EMiG7ppD9J9PGnxxztWlur9FxZhTrv8DVa0CF5OJYFYJMDARLzjh0MmDWYHaXLenkSVE cvHUjSL7RDDo7aUFm8j4JyrqfS9zTt8VZlMKMYzkD0nxw79yeE+5NM705NMQSyx+n9At OYXQ== X-Gm-Message-State: ANoB5pknU8XMoiAAbe6i3vVfm70/1lB44K1RItBVdcPwz44sy5jmkrCG VFwmDDA1QcU2S+XzFCB10mnWPQ== X-Received: by 2002:a17:90b:19c2:b0:21c:6ee5:3b83 with SMTP id nm2-20020a17090b19c200b0021c6ee53b83mr573445pjb.93.1670490477947; Thu, 08 Dec 2022 01:07:57 -0800 (PST) Received: from [10.94.58.189] ([139.177.225.254]) by smtp.gmail.com with ESMTPSA id f15-20020a170902ce8f00b00189947bd9f7sm16152303plg.50.2022.12.08.01.07.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 08 Dec 2022 01:07:57 -0800 (PST) Message-ID: Date: Thu, 8 Dec 2022 17:07:52 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH] Reduce rq lock contention in load_balance() To: chenying , mingo@redhat.com, Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Benjamin Segall Cc: linux-kernel References: Content-Language: en-US From: Abel Wu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Hi Ying, On 11/24/22 5:07 PM, chenying wrote: > ... > diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h > index a4a20046e586..384690bda8c3 100644 > --- a/kernel/sched/sched.h > +++ b/kernel/sched/sched.h > @@ -954,6 +954,7 @@ struct balance_callback { >  struct rq { >      /* runqueue lock: */ >      raw_spinlock_t        __lock; > +    raw_spinlock_t          lb_lock; Do we really need a new lock for doing this? I may suggest the following: diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 87522c3de7b2..30d84e066a9a 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1048,6 +1048,7 @@ struct rq { struct balance_callback *balance_callback; + unsigned char balancing; unsigned char nohz_idle_balance; unsigned char idle_balance; and skip in-balancing runqueues early when find_busiest_queue(). Thanks, Abel > >      /* >       * nr_running and cpu_load should be in the same cacheline because