From patchwork Thu Mar 15 04:41:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 886119 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 401x2S6YK7z9sVT for ; Thu, 15 Mar 2018 15:49:20 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="rtZXT5OU"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 401x2S51bNzDqqN for ; Thu, 15 Mar 2018 15:49:20 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="rtZXT5OU"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c00::242; helo=mail-pf0-x242.google.com; envelope-from=kernelfans@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="rtZXT5OU"; dkim-atps=neutral Received: from mail-pf0-x242.google.com (mail-pf0-x242.google.com [IPv6:2607:f8b0:400e:c00::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 401wtF1Tp4zF196 for ; Thu, 15 Mar 2018 15:42:13 +1100 (AEDT) Received: by mail-pf0-x242.google.com with SMTP id h19so2392786pfd.12 for ; Wed, 14 Mar 2018 21:42:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FWniJUkS6JT8d0IDRR51EMWaoGlafjAvjo9exRnNtiI=; b=rtZXT5OU2f9gDRWWAFDC7i3P8EFW76CzpXpTCOUeHMjmORtAU4865mgTOUKw++wda4 ZFhlaNujvsbJIfquDTU4jKh+/8IBcAEOqSoY+tHqYkA+DLsVGLUv6IZ0vJV9jQsWGa7K V/I57DRYLcBN9zLcC5AIvn40CZnRlVwn6TLq6njTmOMntZGUeKCwrBUscP67Nd8o5ZYX lI7fGO5rjrEFGZAHyCXunZK66NCfKAri4+O8wSOnWIuo0emprm8IlhVbWCnjRvrRKmvb ElIc7WRG3IoEnpFuINWkQPgAQYW0+h+8RlpK0nCc/ug36H56tAo70c4xdSIMGfHRtiBF MgYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FWniJUkS6JT8d0IDRR51EMWaoGlafjAvjo9exRnNtiI=; b=K9334BJj20sQf+fQ4s0055lDgx0t/CaYy3rTH1lmlwzW+SjkPyXCMCzsVFKt/GtfHN gAygXJE+9Q6wf1RrHmJevlgjbhIHK7xwi579n+u/Ev9k5O7aPx2B9zy2tfd96BD71SR0 r18V1lSJSSXx7ZRGIjMVns0z1/vKwm6hwZeGn/S4Jy9PTxY47qMw3zGn5DrpMX0vYkC4 32ND7Xu7S68NWi7wJ6ajcWb5xtaDZyYeHPrOLZ03nRj6ugx6vIaNv1UE+oWtGn6SQz90 jtM3VkhyGvgM/sL38cbS9aoCuMbH0E+GyESK1xbbGIC0kQUbc+lYRo94Akp/W38c+WUL WdHw== X-Gm-Message-State: AElRT7FE267sL8xuJByrk+oVgXCAZuF+oXXXtUhsjjSqxsW/GhPHPKSi 5ImgR39oh0cBq3HwQSNVBfSC X-Google-Smtp-Source: AG47ELsgH/69/5ZHxzVL0TH2oaRNLKnMEcqQ5ART6oWfG3l3Muvv3fBLiJJTpbZpMGl/gIrZetDQjA== X-Received: by 10.99.146.14 with SMTP id o14mr5712820pgd.309.1521088931372; Wed, 14 Mar 2018 21:42:11 -0700 (PDT) Received: from mylaptop.nay.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id v4sm6856781pgq.8.2018.03.14.21.42.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Mar 2018 21:42:09 -0700 (PDT) From: Pingfan Liu To: linuxppc-dev@lists.ozlabs.org Subject: [PATCHv5 2/3] powerpc, cpu: handling the special case when boot_cpuid greater than nr_cpus Date: Thu, 15 Mar 2018 12:41:51 +0800 Message-Id: <1521088912-31742-3-git-send-email-kernelfans@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521088912-31742-1-git-send-email-kernelfans@gmail.com> References: <1521088912-31742-1-git-send-email-kernelfans@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: cascardo@canonical.com, gpiccoli@linux.vnet.ibm.com, kexec@lists.infradead.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" For kexec -p, after boot_cpuid is mapping into the range of [0, threads_per_core), then if nr_cpus is small, we will have the bitmap [0,..., nr_cpus, ..., boot_cpuid, ...). This patch chooses cpus inside the range of [boot_cpuid - nr_cpus +1, ..., boot_cpuid] to be online. With this patch and the next, on a P9 machine with thread_per_core=4, and set nr_cpus=2 for the crash kernel. After taskset -c 11 sh -c "echo c > /proc/sysrq-trigger" Then kdump:/sys/devices/system/cpu# cat possible 2-3 kdump:/sys/devices/system/cpu# cat present 2-3 kdump:/sys/devices/system/cpu# cat online 2-3 Signed-off-by: Pingfan Liu --- arch/powerpc/kernel/setup-common.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c index a683ed1..f3aaf9f 100644 --- a/arch/powerpc/kernel/setup-common.c +++ b/arch/powerpc/kernel/setup-common.c @@ -468,6 +468,7 @@ void __init smp_setup_cpu_maps(void) int online_num = 0; int next_cpu = boot_dn_nthreads; bool btdn_handled = false; + int first_threadid = 0; DBG("smp_setup_cpu_maps()\n"); @@ -497,7 +498,12 @@ void __init smp_setup_cpu_maps(void) if (boot_cpuid < nthreads && be32_to_cpu(intserv[boot_cpuid]) == boot_cpuhwid) { - cpu = 0; + /* choose a bunch of continous threads */ + if (boot_cpuid > nr_cpu_ids - 1) { + first_threadid = boot_cpuid - nr_cpu_ids + 1; + } + /* keep the mapping of logical and thread */ + cpu = first_threadid; btdn_handled = true; } else if ( !btdn_handled && nr_cpu_ids - online_num <= boot_dn_nthreads) @@ -509,7 +515,8 @@ void __init smp_setup_cpu_maps(void) } - for (j = 0; j < nthreads && online_num < nr_cpu_ids; j++) { + for (j = first_threadid; + j < nthreads && online_num < nr_cpu_ids; j++) { bool avail; DBG(" thread %d -> cpu %d (hard id %d)\n",