From patchwork Thu Aug 17 16:14:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 110326 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2403048obb; Thu, 17 Aug 2017 09:15:11 -0700 (PDT) X-Received: by 10.84.232.76 with SMTP id f12mr6279416pln.249.1502986511099; Thu, 17 Aug 2017 09:15:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502986511; cv=none; d=google.com; s=arc-20160816; b=h48R9omQJt0nMnKE1mAFkXvdxKaso0btLgXpnmVSrJq1JF4TvBB7TEPNXc0gS8yRsT q+SmjeaDi6AHNDQPi/fgQrvpWq9mUAKTGWVJf7UpaZQjFjFJhtoGhM7fKrOee7ZNhGuj Qe2TplvQKo8zmcIZVNtQrC+YHuz5O1uKLhY2kGSc8NijlYF7CZx+ha5LZikLGz1wTIcO LXxsKgHASkGJ27jfTcrReTGVZggOuFdsT/8AdPc5C8QjNLn3KSZS6OC0lCxxlLoJ0z5Q u4+dZfJwpIJgbheY5fkXFmHVJF1hq1RXX8zzuAnd8TWQqnE5O5AVLp7rL1nqVbuz+8LY +h1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=ysh7MiEmVUQiWNfD5eucdEXTK+nQmuIKtNH30zVfYO4=; b=tg+laJC2xnuyPmKwSjatLY6zq7FGxGlwXBqszOoJ8miXTs4GZXL7uaJ4p1xj4jSjBR gsf3sOyTmz+rUKB0inHb0aXRAKZfOnlKNEKbsNHtBFKZ2YYwidE8BRT4QKO02hoOxwtZ BhPFmV4zQ3llaoSelIlFnrF4kInjEe/oM5IiJ6xuV6RWwyAE0/ycsJedPI8T7xXa05Bn oK/T4WBOTvVbfFIQIPZD1h7ISgNBhpYEUBNWET89fupZxEFXS4o8oQ+VmSZR7XwHFAS4 e6TcE+zICu+0qzxmhfVq1kYnbzll69O+JvD+Pw3cZ0XKq0BkglcBPS+7GHZx38EBvdq5 nFHg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c12si2312321pfe.239.2017.08.17.09.15.10; Thu, 17 Aug 2017 09:15:11 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753225AbdHQQPG (ORCPT + 26 others); Thu, 17 Aug 2017 12:15:06 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:52504 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752450AbdHQQPE (ORCPT ); Thu, 17 Aug 2017 12:15:04 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 30573164F; Thu, 17 Aug 2017 09:15:04 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2181B3F577; Thu, 17 Aug 2017 09:15:02 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Cc: boris.ostrovsky@oracle.com, jgross@suse.com, linux-kernel@vger.kernel.org, Julien Grall Subject: [PATCH] xen/events: events_fifo: Don't use {get, put}_cpu() in xen_evtchn_fifo_init() Date: Thu, 17 Aug 2017 17:14:53 +0100 Message-Id: <20170817161453.19318-2-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170817161453.19318-1-julien.grall@arm.com> References: <20170817161453.19318-1-julien.grall@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When booting Linux as Xen guest with CONFIG_DEBUG_ATOMIC, the following splat appears: [ 0.002323] Mountpoint-cache hash table entries: 1024 (order: 1, 8192 bytes) [ 0.019717] ASID allocator initialised with 65536 entries [ 0.020019] xen:grant_table: Grant tables using version 1 layout [ 0.020051] Grant table initialized [ 0.020069] BUG: sleeping function called from invalid context at /data/src/linux/mm/page_alloc.c:4046 [ 0.020100] in_atomic(): 1, irqs_disabled(): 0, pid: 1, name: swapper/0 [ 0.020123] no locks held by swapper/0/1. [ 0.020143] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.13.0-rc5 #598 [ 0.020166] Hardware name: FVP Base (DT) [ 0.020182] Call trace: [ 0.020199] [] dump_backtrace+0x0/0x270 [ 0.020222] [] show_stack+0x24/0x30 [ 0.020244] [] dump_stack+0xb8/0xf0 [ 0.020267] [] ___might_sleep+0x1c8/0x1f8 [ 0.020291] [] __might_sleep+0x58/0x90 [ 0.020313] [] __alloc_pages_nodemask+0x1c0/0x12e8 [ 0.020338] [] alloc_page_interleave+0x38/0x88 [ 0.020363] [] alloc_pages_current+0xdc/0xf0 [ 0.020387] [] __get_free_pages+0x28/0x50 [ 0.020411] [] evtchn_fifo_alloc_control_block+0x2c/0xa0 [ 0.020437] [] xen_evtchn_fifo_init+0x38/0xb4 [ 0.020461] [] xen_init_IRQ+0x44/0xc8 [ 0.020484] [] xen_guest_init+0x250/0x300 [ 0.020507] [] do_one_initcall+0x44/0x130 [ 0.020531] [] kernel_init_freeable+0x120/0x288 [ 0.020556] [] kernel_init+0x18/0x110 [ 0.020578] [] ret_from_fork+0x10/0x40 [ 0.020606] xen:events: Using FIFO-based ABI [ 0.020658] Xen: initializing cpu0 [ 0.027727] Hierarchical SRCU implementation. [ 0.036235] EFI services will not be available. [ 0.043810] smp: Bringing up secondary CPUs ... This is because get_cpu() in xen_evtchn_fifo_init() will disable preemption, but __get_free_page() might sleep (GFP_ATOMIC is not set). xen_evtchn_fifo_init() will always be called before SMP is initialized, so {get,put}_cpu() could be replaced by a simple smp_processor_id(). This also avoid to modify evtchn_fifo_alloc_control_block that will be called in other context. Signed-off-by: Julien Grall Reported-by: Andre Przywara Fixes: 1fe565517b57 ("xen/events: use the FIFO-based ABI if available") --- drivers/xen/events/events_fifo.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) -- 2.11.0 diff --git a/drivers/xen/events/events_fifo.c b/drivers/xen/events/events_fifo.c index 3c41470c7fc4..76b318e88382 100644 --- a/drivers/xen/events/events_fifo.c +++ b/drivers/xen/events/events_fifo.c @@ -432,12 +432,12 @@ static int xen_evtchn_cpu_dead(unsigned int cpu) int __init xen_evtchn_fifo_init(void) { - int cpu = get_cpu(); + int cpu = smp_processor_id(); int ret; ret = evtchn_fifo_alloc_control_block(cpu); if (ret < 0) - goto out; + return ret; pr_info("Using FIFO-based ABI\n"); @@ -446,7 +446,6 @@ int __init xen_evtchn_fifo_init(void) cpuhp_setup_state_nocalls(CPUHP_XEN_EVTCHN_PREPARE, "xen/evtchn:prepare", xen_evtchn_cpu_prepare, xen_evtchn_cpu_dead); -out: - put_cpu(); + return ret; }