Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1723174imm; Thu, 20 Sep 2018 01:40:30 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaSljhJOUA5qC+SZtGzudIUBjPy7GbdjpPS1b+Fg6Du/cJiG7LyoMv0awwzWPFUlMQ5PESK X-Received: by 2002:a63:b507:: with SMTP id y7-v6mr36599130pge.425.1537432830752; Thu, 20 Sep 2018 01:40:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537432830; cv=none; d=google.com; s=arc-20160816; b=A9InjrfEYgkfSmTUvfAyX7P3FsFmmNElxNLvOd12rYii6sGlBWOrnEnYm0UVENqJsn OyqCKXoluqsqyu010A2fSquudkiaYzrfxnm62Dkb0V7hH4kixxZwCq72VhlCxjwMCAvr ceHhad+mRY+5ZxHl+OcxCZH+27dgFDjOcw+KYVU0s4sQwWzNDJwfUhd8KBQHbViZ84ut nelhSn8hmh7+VcbPBioSY4S0SxkY0qS1ymhgiT4xgqr7i8etNLOokCtoOu+bPkLAPuC3 I3FsLfEJwJ+487qZ+xA/x63CCDhkJziv3l8KODOAYYqC9yAMH7MRpAdYmY7OwU0hBDV3 U/zQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date :thread-index:mime-version:in-reply-to:references:from :dkim-signature; bh=rzJiNLWHOCrBj8W0kDSSC6EolcogxAS7Qdfxbo53SxI=; b=BGSnZOmC28eG663/ufpvkFP8JVFkUfsBN0hvhRm32o3yIL6tYNUyh4ROwkR6bccmnS kHZBDU+l6QUb5SLG6nVonoyuy73KHqIJK9d2mZ+LnExhIqX0qaJeY6bz0G7AbBH0oiIp N1OuhxscimAwgHrLbl/PQJzeO6TRMtuvZid4e4Kq6tIBHWzxkiv+n2lFAkvjOZ6Q3Lpv foCkC9NK6qL4+j1UDqdvZVgewRFAJSjg4e5E9RbGD9vGDKvjw2VccEq2iflz/mEftJZf t5Yb3fT5OcnZnXv1QBXtKqFt08wDV33UvqvXy7E+FuVEwjAgQ+uUje2VxxP2/qJ9qTIb /VTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=WZCyqQ8a; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t10-v6si22928596plz.414.2018.09.20.01.40.01; Thu, 20 Sep 2018 01:40:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=WZCyqQ8a; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731304AbeITOWQ (ORCPT + 99 others); Thu, 20 Sep 2018 10:22:16 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:35959 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726383AbeITOWQ (ORCPT ); Thu, 20 Sep 2018 10:22:16 -0400 Received: by mail-io1-f67.google.com with SMTP id q5-v6so6750424iop.3 for ; Thu, 20 Sep 2018 01:39:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:references:in-reply-to:mime-version:thread-index:date :message-id:subject:to:cc; bh=rzJiNLWHOCrBj8W0kDSSC6EolcogxAS7Qdfxbo53SxI=; b=WZCyqQ8aqIF9VhH7bCSzdqKzdePiRjdE6P/xyvExygzMhfAW0rVtc2M3F1WbrF70Db OX8LWZcRI/zkHj7wZFXNl9lznGV10rYj0J41wWtDMq3X6qrbemxL8vIvQpO5YEtpU//i bI6Uj1MYQ2Em4WiDQMatLVHJhhcSXo42JOCwU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:references:in-reply-to:mime-version :thread-index:date:message-id:subject:to:cc; bh=rzJiNLWHOCrBj8W0kDSSC6EolcogxAS7Qdfxbo53SxI=; b=djm/H7NswR9RXS37uhLo1se17O2rQyD2qWFDhmgOuHpIR3mfUwi6qHFtw/M/VZZsKm y3cI5S6L8TxVZ0lYFYrooV7UBDNWIOYBpj1yqD7XDBsSr/v9wzCRKVvtUanfWmkBvFlM vCJRUgtM++544c4vhbdaVK2nGYZvoKPKZwWna+y4mbcrKUuM1I8FFJcJKCUJMoAqNzsj 2d5rp1SmcgNQTa61zfi9/iITegTMc7+HFB8+IaoEdlC+8LYBa16W+CF8bcoNIEBXiQHN KO0kspgv1U4Y4yQsEJVuFoDDccdGpaeQkkKhavZpfXzKDkpd1aWrObeOFJ+BJIC2Bt4/ yEFw== X-Gm-Message-State: ABuFfohH4mxU9lW0edFewgOLSvsoeMm8WkFhL7xYfEdO8wgUUF64Vd92 bnNEMkxpaf28pJAZdscdwb1GEF2mo90r/px/Ncc2bQ== X-Received: by 2002:a6b:b242:: with SMTP id b63-v6mr7724854iof.172.1537432795213; Thu, 20 Sep 2018 01:39:55 -0700 (PDT) From: Kashyap Desai References: <20180913031011.17376-1-dou_liyang@163.com> In-Reply-To: MIME-Version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQGvGgMD28WSn01TP3Q+HMY40wYaWwJRtWcwpSvYmlA= Date: Thu, 20 Sep 2018 14:09:53 +0530 Message-ID: Subject: RE: [RFC PATCH] irq/affinity: Mark the pre/post vectors as regular interrupts To: Thomas Gleixner , Dou Liyang Cc: LKML , Shivasharan Srikanteshwara , Sumit Saxena , ming.lei@redhat.com, Christoph Hellwig , douly.fnst@cn.fujitsu.com, Bjorn Helgaas Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > This is the wrong direction as it does not allow to do initial affinity > assignement for the non-managed interrupts on allocation time. And that's > what Kashyap and Sumit are looking for. > > The trivial fix for the possible breakage when irq_default_affinity != > cpu_possible_mask is to set the affinity for the pre/post vectors to > cpu_possible_mask and be done with it. > > One other thing I noticed while staring at that is the fact, that the PCI > code does not care about the return value of irq_create_affinity_masks() at > all. It just proceeds if masks is NULL as if the stuff was requested with > the affinity descriptor pointer being NULL. I don't think that's a > brilliant idea because the drivers might rely on the interrupt being > managed, but it might be a non-issue and just result in bad locality. > > Christoph? > > So back to the problem at hand. We need to change the affinity management > scheme in a way which lets us differentiate between managed and > unmanaged > interrupts, so it allows to automatically assign (initial) affinity to all > of them. > > Right now everything is bound to the cpumasks array, which does not allow > to convey more information. So we need to come up with something > different. > > Something like the below (does not compile and is just for reference) > should do the trick. I'm not sure whether we want to convey the information > (masks and bitmap) in a single data structure or not, but that's an > implementation detail. Dou - Do you want me to test your patch or shall I wait for next version ? > > Thanks, > > tglx > > 8<--------- > --- a/drivers/pci/msi.c > +++ b/drivers/pci/msi.c > @@ -535,15 +535,16 @@ static struct msi_desc * > msi_setup_entry(struct pci_dev *dev, int nvec, const struct irq_affinity *affd) > { > struct cpumask *masks = NULL; > + unsigned long managed = 0; > struct msi_desc *entry; > u16 control; > > if (affd) > - masks = irq_create_affinity_masks(nvec, affd); > + masks = irq_create_affinity_masks(nvec, affd, &managed); > > > /* MSI Entry Initialization */ > - entry = alloc_msi_entry(&dev->dev, nvec, masks); > + entry = alloc_msi_entry(&dev->dev, nvec, masks, managed); > if (!entry) > goto out; > > @@ -672,15 +673,22 @@ static int msix_setup_entries(struct pci > struct msix_entry *entries, int nvec, > const struct irq_affinity *affd) > { > + /* > + * MSIX_MAX_VECTORS = 2048, i.e. 256 bytes. Might need runtime > + * allocation. OTOH, are 2048 vectors realistic? > + */ > + DECLARE_BITMAP(managed, MSIX_MAX_VECTORS); > struct cpumask *curmsk, *masks = NULL; > struct msi_desc *entry; > int ret, i; > > if (affd) > - masks = irq_create_affinity_masks(nvec, affd); > + masks = irq_create_affinity_masks(nvec, affd, managed); > > for (i = 0, curmsk = masks; i < nvec; i++) { > - entry = alloc_msi_entry(&dev->dev, 1, curmsk); > + unsigned long m = test_bit(i, managed) ? 1 : 0; > + > + entry = alloc_msi_entry(&dev->dev, 1, curmsk, m); > if (!entry) { > if (!i) > iounmap(base); > --- a/kernel/irq/msi.c > +++ b/kernel/irq/msi.c > @@ -27,7 +27,8 @@ > * and the affinity masks from @affinity are copied. > */ > struct msi_desc * > -alloc_msi_entry(struct device *dev, int nvec, const struct cpumask *affinity) > +alloc_msi_entry(struct device *dev, int nvec, const struct cpumask *affinity, > + unsigned long managed) > { > struct msi_desc *desc; > > @@ -38,6 +39,7 @@ alloc_msi_entry(struct device *dev, int > INIT_LIST_HEAD(&desc->list); > desc->dev = dev; > desc->nvec_used = nvec; > + desc->managed = managed; > if (affinity) { > desc->affinity = kmemdup(affinity, > nvec * sizeof(*desc->affinity), GFP_KERNEL); > @@ -416,7 +418,7 @@ int msi_domain_alloc_irqs(struct irq_dom > > virq = __irq_domain_alloc_irqs(domain, -1, desc->nvec_used, > dev_to_node(dev), &arg, false, > - desc->affinity); > + desc->affinity, desc->managed); > if (virq < 0) { > ret = -ENOSPC; > if (ops->handle_error)