Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp844128rdb; Fri, 20 Oct 2023 00:26:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFvMI9LTtJWWOJJsenXKxgTFN2Xt9Zh3YLqnzHGdjOGq7r0bWBhf/mzoyNFAQxoZAVukyR8 X-Received: by 2002:a17:90a:191:b0:27d:66bd:1c2e with SMTP id 17-20020a17090a019100b0027d66bd1c2emr1081843pjc.7.1697786803180; Fri, 20 Oct 2023 00:26:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697786803; cv=none; d=google.com; s=arc-20160816; b=cukbRUZL45wQ24g7V327RKby5bekuynPoSAF3DMWf4qN6WY4qibSxOwK1tor1NHDPA CNH5DwLXhHzpM+M9gK5BfopsR/SgyxO7LvyBB/g1Lwdbz05/zP2S6S7PNLeZlPWLn3tO 3WLDf0PGtNL/SeISuJpKO1JcwmupoNsdkEOyp4pQ6jVwH/Q/tZDwvnlDmOcGyVe73Ert 6gRotD/2fENUIzfj9zynP/ug07BoVubSV7vl5A8mszasWfwHVp61ndarLQDa7T5HLwH6 fqgyroI85nkh7qW0YTuz5n/GIaliDg8j2Mw+wMzyASsRlc4ffxDgYaLmSPC2BJPGxmnr Xigg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=NlWH/F5sgTwWyHpx5vmdRZzA0svGz648g56NOLAtYIk=; fh=j00LVE0wQVM9dZdbn8VBH3/loDuE8URTfFphFTGzvL4=; b=EZhoSBVAzB2rM8xgiWyd3zBd2TZQ0GW9tYKQVh7cJnedQ0wQExqBoYewGr06fHsLh1 ACxX0v+DD4J+0jZJkaTF4eDNbBBzrp5Ex+2YJYNG5AtSD3yTvCkuQjra+oG74EIY5D2r W10DkFzAmdGi+Kp+vvpQbj746EIcSjjiMCn41qQAF1DhOSV+7kWk2tIZoZPAOx7nVcq2 3l1znzp4qwkuyY7oh14pLJqfZfgFres3tYfaPn4LsiJKr2vkYKM2WNt6uElYRKSM97TF yTvx1YIF4/BBo3DozhLMZLKtIySR79RiTg6rwNow2axEmn2n8TmwBagS9nS76/GkFEnp 4Uvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hyRvOgb4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id kk3-20020a17090b4a0300b00278ea235413si4092330pjb.31.2023.10.20.00.26.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 00:26:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hyRvOgb4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 11C7C82A45D1; Fri, 20 Oct 2023 00:26:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376317AbjJTH0f (ORCPT + 99 others); Fri, 20 Oct 2023 03:26:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230371AbjJTH0e (ORCPT ); Fri, 20 Oct 2023 03:26:34 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2D8C91 for ; Fri, 20 Oct 2023 00:26:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697786792; x=1729322792; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=ydwo0c6r0LCE+PTbYHOXBNKfMzBtuYnakBz475nDoL8=; b=hyRvOgb4IK9cOtpdXhlRhp1B7s8YFG+m8DuoB2Y33R8DaN64FZq7kJnh ehWDeTwUaUMiUOrwpSO1/sxgR/9kFhHB4MuTtSUzgLcheEeB4QdiMFYsW YD82HivM8Y5QDdF5H6KPHsxulDGi53imdxJpzMPiZVtuV+sbZgPbmZRbS Wi8PfzqvDj9O1OymfeayvHfQx/GljFFVvJPQqFotOoz/c6LiHjXkn8Kz7 g7mKyMuEnH5Y51DAOeWMMZ1OsAk1JW9RbSIvTcVYcfcrRA0f/mLPFsbrJ YESQbk3U9SkySRBoU8L3gbos81XAKkRbyPPnbBf7dvLkBmEdBoQqA8L6e w==; X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="385322922" X-IronPort-AV: E=Sophos;i="6.03,238,1694761200"; d="scan'208";a="385322922" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2023 00:26:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="792309680" X-IronPort-AV: E=Sophos;i="6.03,238,1694761200"; d="scan'208";a="792309680" Received: from chenyu-dev.sh.intel.com ([10.239.62.164]) by orsmga001.jf.intel.com with ESMTP; 20 Oct 2023 00:26:28 -0700 From: Chen Yu To: Thomas Gleixner , Juergen Gross Cc: Len Brown , "Rafael J . Wysocki" , Dan Williams , linux-kernel@vger.kernel.org, Chen Yu , Chen Yu , Wendy Wang Subject: [RFC PATCH] genirq: Exclude managed irq during irq migration Date: Fri, 20 Oct 2023 15:25:22 +0800 Message-Id: <20231020072522.557846-1-yu.c.chen@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 20 Oct 2023 00:26:41 -0700 (PDT) The managed IRQ will be shutdown and not be migrated to other CPUs during CPU offline. Later when the CPU is online, the managed IRQ will be re-enabled on this CPU. The managed IRQ can be used to reduce the IRQ migration during CPU hotplug. Before putting the CPU offline, the number of the already allocated IRQs on this offlining CPU will be compared to the total number of available IRQ vectors on the remaining online CPUs. If there is not enough slot for these IRQs to be migrated to, the CPU offline will be terminated. However, currently the code treats the managed IRQ as migratable, which is not true, and brings false negative during CPU hotplug and hibernation stress test. For example: cat /sys/kernel/debug/irq/domains/VECTOR name: VECTOR size: 0 mapped: 338 flags: 0x00000103 Online bitmaps: 168 Global available: 33009 Global reserved: 83 Total allocated: 255 <------ System: 43: 0-21,50,128,192,233-236,240-242,244,246-255 | CPU | avl | man | mac | act | vectors 0 180 1 1 18 32-49 1 196 1 1 2 32-33 ... 166 197 1 1 1 32 167 197 1 1 1 32 //put CPU167 offline pepc.standalone cpu-hotplug offline --cpus 167 cat /sys/kernel/debug/irq/domains/VECTOR name: VECTOR size: 0 mapped: 338 flags: 0x00000103 Online bitmaps: 167 Global available: 32812 Global reserved: 83 Total allocated: 254 <------ System: 43: 0-21,50,128,192,233-236,240-242,244,246-255 | CPU | avl | man | mac | act | vectors 0 180 1 1 18 32-49 1 196 1 1 2 32-33 ... 166 197 1 1 1 32 After CPU167 is offline, the number of allocated vectors decreases from 255 to 254. Since the only IRQ on CPU167 is managed(mac field), it is not migrated. But the current code thinks that there is 1 IRQ to be migrated. Fix the check by substracting the number of managed IRQ from allocated one. Fixes: 2f75d9e1c905 ("genirq: Implement bitmap matrix allocator") Reported-by: Wendy Wang Signed-off-by: Chen Yu --- kernel/irq/matrix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/irq/matrix.c b/kernel/irq/matrix.c index 1698e77645ac..d245ad76661e 100644 --- a/kernel/irq/matrix.c +++ b/kernel/irq/matrix.c @@ -475,7 +475,7 @@ unsigned int irq_matrix_allocated(struct irq_matrix *m) { struct cpumap *cm = this_cpu_ptr(m->maps); - return cm->allocated; + return cm->allocated - cm->managed_allocated; } #ifdef CONFIG_GENERIC_IRQ_DEBUGFS -- 2.25.1