Received: by 10.223.164.202 with SMTP id h10csp659505wrb; Wed, 22 Nov 2017 13:12:52 -0800 (PST) X-Google-Smtp-Source: AGs4zMYxbMaVjFVsuF3izpFKgZ5WvN8oq4Wnl1rBpC1ajjq8t0XmyDiRPKMh7NbggnrN2d1NqpMJ X-Received: by 10.101.68.129 with SMTP id l1mr21803274pgq.4.1511385172674; Wed, 22 Nov 2017 13:12:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511385172; cv=none; d=google.com; s=arc-20160816; b=d04Lqx51jZHFlmWxlpgU65lpCa9ymvM145ATOkXKrHZGlfC41HJC+cicRbyZqjuUK4 fa2I9Df6S9r6tzK0HIkIUSnSd1UJfHmtbiDdGH0OQvo0V47vq8l4WAM1HhtI6c7GZllp mvK5N1dKOfZwvCDH7lRZaiGpGKhXuuU0zT/YuU3XlyjymKyqqXmM4YWmnSv0+XeLxKcO dJjCVATqQEcnV6H1wSeQpp1yj8u6u7lF0H3NmVkq5sSitzgkk9HPfZqQiUfcEMdPPksN 9vhzIyY1Oodv51CqPGqVR5hAQcY9gGtMqj7LNgVwUipqWSN/q2PnHWGv9hjm3j4RFjq7 h7pg== 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:dkim-signature:arc-authentication-results; bh=fRFaCzBfp5ytsjJK8Z25W1rZIZUYoSDJR3qaYIHcWKc=; b=tT5CWc/HFc2PwU9VdVYl1jgUoPIUNBBN2nl9neqFGjYrfxztA8NUjf8e8E/l/J9KmZ KWGXZA4E2rVRh7m8x+borKJrrcFBRB+VM4etU1EIyqkljIAUANXoFztJScSxxjrMR1ES QO6bjENbkwX9ZyMgvMqW7yRzORSsl8UlXctPV1o77/NRlBBvZrOSX8N+p5DjsiSAK8c1 LcTblMqWD6bz9JhE8silyevP0Cky6c0lIYzimqEtvcTgOVl8FxWNiQ/GwfmZkUenh0EL Cp0r43UIhzUPAxaamMx/qwX+7lG+zUJfBRj4VomTmFXONcJFsnYAr/rjVAWL+niuO+A4 cORw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=bRcWZiCi; 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 g207si15622528pfb.190.2017.11.22.13.12.41; Wed, 22 Nov 2017 13:12:52 -0800 (PST) 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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=bRcWZiCi; 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 S1751673AbdKVVLG (ORCPT + 77 others); Wed, 22 Nov 2017 16:11:06 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:39306 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751876AbdKVVIU (ORCPT ); Wed, 22 Nov 2017 16:08:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=fRFaCzBfp5ytsjJK8Z25W1rZIZUYoSDJR3qaYIHcWKc=; b=bRcWZiCipepMuI9PxeOQjObYH CvU7SQV7f8wRXopexmu9GQOQsrBZfH8JhE6jJnMEIAtYeDWudm7uzKNeXUwIPDHFnjK+wEx/6v9HO YUiVf7GxfTBKx6H+K66u7Z7oJiviMDpRIPAzNbD24DrdFUa0gj+UiOZohk/ZIfSmNb0QV95I0vGQC +B8V/WqXi7SnJhHQ81//zwEG9wnjyRkFmNV9HaxyczI55n0Rme7fvOy73Ic4oYrnrsRNHwUZmewHC wimLyxJT+vosCja846VmXulHW5CreWXCG16CJPhqe9xxbEQnvVj3LjkfRwiVmRxYysv58913PoJqm 4l4bGFPGg==; Received: from willy by bombadil.infradead.org with local (Exim 4.87 #1 (Red Hat Linux)) id 1eHcFo-0007yQ-51; Wed, 22 Nov 2017 21:08:20 +0000 From: Matthew Wilcox To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Matthew Wilcox Subject: [PATCH 55/62] firewire: Remove call to idr_preload Date: Wed, 22 Nov 2017 13:07:32 -0800 Message-Id: <20171122210739.29916-56-willy@infradead.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171122210739.29916-1-willy@infradead.org> References: <20171122210739.29916-1-willy@infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthew Wilcox core-cdev uses a spinlock to protect several elements, including the IDR. Rather than reusing the IDR's spinlock for all of this, preallocate the necessary memory by allocating a NULL pointer and then replace it with the resource pointer once we have the spinlock. Signed-off-by: Matthew Wilcox --- drivers/firewire/core-cdev.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index a301fcf46e88..52c22c39744e 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c @@ -486,28 +486,24 @@ static int ioctl_get_info(struct client *client, union ioctl_arg *arg) static int add_client_resource(struct client *client, struct client_resource *resource, gfp_t gfp_mask) { - bool preload = gfpflags_allow_blocking(gfp_mask); unsigned long flags; int ret; - if (preload) - idr_preload(gfp_mask); - spin_lock_irqsave(&client->lock, flags); + ret = idr_alloc(&client->resource_idr, NULL, 0, 0, gfp_mask); + if (ret < 0) + return ret; - if (client->in_shutdown) + spin_lock_irqsave(&client->lock, flags); + if (client->in_shutdown) { + idr_remove(&client->resource_idr, ret); ret = -ECANCELED; - else - ret = idr_alloc(&client->resource_idr, resource, 0, 0, - GFP_NOWAIT); - if (ret >= 0) { + } else { + idr_replace(&client->resource_idr, resource, ret); resource->handle = ret; client_get(client); schedule_if_iso_resource(resource); } - spin_unlock_irqrestore(&client->lock, flags); - if (preload) - idr_preload_end(); return ret < 0 ? ret : 0; } -- 2.15.0 From 1584808302587834155@xxx Wed Nov 22 22:49:34 +0000 2017 X-GM-THRID: 1584808302587834155 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread