Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932923AbdC2Rq3 (ORCPT ); Wed, 29 Mar 2017 13:46:29 -0400 Received: from mga09.intel.com ([134.134.136.24]:14098 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932353AbdC2RqI (ORCPT ); Wed, 29 Mar 2017 13:46:08 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,242,1486454400"; d="scan'208";a="1148466344" Date: Wed, 29 Mar 2017 13:54:15 -0400 From: Keith Busch To: Sagi Grimberg Cc: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, Thomas Gleixner , Christoph Hellwig Subject: Re: [PATCH] irq/affinity: Assign all CPUs a vector Message-ID: <20170329175415.GD20181@localhost.localdomain> References: <1490743277-14139-1-git-send-email-keith.busch@intel.com> <6e7a93a7-b0bb-8835-6c49-3eaa3203e1d8@grimberg.me> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6e7a93a7-b0bb-8835-6c49-3eaa3203e1d8@grimberg.me> User-Agent: Mutt/1.7.0 (2016-08-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1392 Lines: 30 On Wed, Mar 29, 2017 at 08:15:50PM +0300, Sagi Grimberg wrote: > > > The number of vectors to assign needs to be adjusted for each node such > > that it doesn't exceed the number of CPUs in that node. This patch > > recalculates the vector assignment per-node so that we don't try to > > assign more vectors than there are CPUs. When that previously happened, > > the cpus_per_vec was calculated to be 0, so many vectors had no CPUs > > assigned. This then goes on to fail to allocate descriptors due to > > empty masks, leading to an unoptimal spread. > > Can you give a specific (numeric) example where this happens? I'm having > a little trouble following the logical change here. Sure, I have a 2-socket server with 16 threads each. I take one CPU offline in socket 2, so I've 16 threads on socket 1, 15 in socket 2. In total, 31 threads so requesting 31 vectors. Currently, vecs_per_node is calculated in the first iteration as 31 / 2, so 15. ncpus of socket 1 is 16. cpus_per_vec = 16 / 15, so 1 CPU per vector with one extra. When iterating the second socket, though, vecs_per_node is incremented from 15 to 16 (to account for the "extra" from before). However, the ncpus is only 15, so that iteration calculates: cpus_per_vec = 15 / 16 And since that's zero, the remaining 16 vectors are not assigned to any CPU, and the second socket has no vectors assigned to their CPUs.