Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1339348imm; Wed, 11 Jul 2018 23:32:12 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeIxZLj+OGnH4WOd5hSp02mPK9kR8Dh2mQGO1Gd3f5mkuzPxW8gQ5HidQe47f+Fm9F3f2s8 X-Received: by 2002:a62:b90f:: with SMTP id z15-v6mr1036746pfe.254.1531377132449; Wed, 11 Jul 2018 23:32:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531377132; cv=none; d=google.com; s=arc-20160816; b=P/cURsyLWELoNYv3vk/YLR8BEEuhC00rHZHbXU4WIr/yzkXWtOhtrmpERhzk6/MYzS DcM/wgTm19vlVNdFwx3ZWCYkmmtxfIs/8iWFhIWItmLdjIedY0ZKebL0y7Tu+Y+DalDO gKJ9AaAOprg7B8Y2jzeqc4aerqimURLWP1EwjnDEE6IFE8b5ef+vMKNNO40DXo6LOWaa N63CGWJKo+eWbkwu1ubiVEvMUfkbnAqtknNbA+ap4EUXCzfcY3swB2uig6z7aZ/mMR48 Bj984aHoNoFDsP7Y06hQT+VWVGYkpCVc09C0TQ7ZLwsRbnyRW9iknBl7p/gyRnWMdfyF i/dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:date:message-id:subject:from:cc:to :arc-authentication-results; bh=UVwTWURLTAgQPvBVm+gEPdo0N2zuk7yGOOrXCdE0rjs=; b=yUhAML4zJeS+HrFf7J2gPFc9LR8Z7YQRevZ6le0wx5OB9+jJkfi5sJ0W76cXqsZ/0j f472xyh+GcOoWTiUjs5T4oDG5Zi+YWUrKRcB6u+EoMPT13DC2WD/EnoUv3HzOXw8Lba5 KU6uqOkDdqvdEXRjc2BGBiAVxUuDfEtkitpH2TCi5LGZusW6zhiHZ/vWVuy72j32aiJQ P8WMxbERIcQnryBau93yv6erxKebzMzQlV1hhAXGWA9Kr9yw6DLNF5ws3L/WTKvRLnEt 6V0Oyn3nK2jtGJQbP4fCSR+SlFw7Nxvw/HrBi79QLIs52krRCiTWGpWnfJZGZ1Cvy2bz +9hw== 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 q1-v6si21202958plb.331.2018.07.11.23.31.57; Wed, 11 Jul 2018 23:32:12 -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 S1727259AbeGLGja (ORCPT + 99 others); Thu, 12 Jul 2018 02:39:30 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:52675 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726854AbeGLGja (ORCPT ); Thu, 12 Jul 2018 02:39:30 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 01AEA2B38CA2A; Thu, 12 Jul 2018 14:31:17 +0800 (CST) Received: from [10.177.253.249] (10.177.253.249) by smtp.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.382.0; Thu, 12 Jul 2018 14:31:13 +0800 To: "akpm@linux-foundation.org" , , , CC: Linux Kernel Mailing List , From: piaojun Subject: [PATCH] net/9p/client.c: fix misuse of spin_lock_irqsave for p9_client lock Message-ID: <5B46F5AD.50200@huawei.com> Date: Thu, 12 Jul 2018 14:31:09 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.253.249] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In p9_read_work(), we use spin_lock for client->lock, but misuse spin_lock_irqsave for it in p9_fid_create(). As p9_client lock won't be locked in irq context, so spin_lock is enough. And that will improve the performance. Signed-off-by: Jun Piao --- net/9p/client.c | 17 +++++++---------- net/9p/trans_fd.c | 7 +++---- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/net/9p/client.c b/net/9p/client.c index 8bc8b3e..b05cbfc 100644 --- a/net/9p/client.c +++ b/net/9p/client.c @@ -260,7 +260,6 @@ static struct p9_fcall *p9_fcall_alloc(int alloc_msize) static struct p9_req_t * p9_tag_alloc(struct p9_client *c, u16 tag, unsigned int max_size) { - unsigned long flags; int row, col; struct p9_req_t *req; int alloc_msize = min(c->msize, max_size); @@ -270,7 +269,7 @@ static struct p9_fcall *p9_fcall_alloc(int alloc_msize) tag++; if (tag >= c->max_tag) { - spin_lock_irqsave(&c->lock, flags); + spin_lock(&c->lock); /* check again since original check was outside of lock */ while (tag >= c->max_tag) { row = (tag / P9_ROW_MAXTAG); @@ -279,7 +278,7 @@ static struct p9_fcall *p9_fcall_alloc(int alloc_msize) if (!c->reqs[row]) { pr_err("Couldn't grow tag array\n"); - spin_unlock_irqrestore(&c->lock, flags); + spin_unlock(&c->lock); return ERR_PTR(-ENOMEM); } for (col = 0; col < P9_ROW_MAXTAG; col++) { @@ -288,7 +287,7 @@ static struct p9_fcall *p9_fcall_alloc(int alloc_msize) } c->max_tag += P9_ROW_MAXTAG; } - spin_unlock_irqrestore(&c->lock, flags); + spin_unlock(&c->lock); } row = tag / P9_ROW_MAXTAG; col = tag % P9_ROW_MAXTAG; @@ -909,7 +908,6 @@ static struct p9_fid *p9_fid_create(struct p9_client *clnt) { int ret; struct p9_fid *fid; - unsigned long flags; p9_debug(P9_DEBUG_FID, "clnt %p\n", clnt); fid = kmalloc(sizeof(struct p9_fid), GFP_KERNEL); @@ -928,9 +926,9 @@ static struct p9_fid *p9_fid_create(struct p9_client *clnt) fid->uid = current_fsuid(); fid->clnt = clnt; fid->rdir = NULL; - spin_lock_irqsave(&clnt->lock, flags); + spin_lock(&clnt->lock); list_add(&fid->flist, &clnt->fidlist); - spin_unlock_irqrestore(&clnt->lock, flags); + spin_unlock(&clnt->lock); return fid; @@ -942,14 +940,13 @@ static struct p9_fid *p9_fid_create(struct p9_client *clnt) static void p9_fid_destroy(struct p9_fid *fid) { struct p9_client *clnt; - unsigned long flags; p9_debug(P9_DEBUG_FID, "fid %d\n", fid->fid); clnt = fid->clnt; p9_idpool_put(fid->fid, clnt->fidpool); - spin_lock_irqsave(&clnt->lock, flags); + spin_lock(&clnt->lock); list_del(&fid->flist); - spin_unlock_irqrestore(&clnt->lock, flags); + spin_unlock(&clnt->lock); kfree(fid->rdir); kfree(fid); } diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c index 588bf88..96e1e68 100644 --- a/net/9p/trans_fd.c +++ b/net/9p/trans_fd.c @@ -197,15 +197,14 @@ static void p9_mux_poll_stop(struct p9_conn *m) static void p9_conn_cancel(struct p9_conn *m, int err) { struct p9_req_t *req, *rtmp; - unsigned long flags; LIST_HEAD(cancel_list); p9_debug(P9_DEBUG_ERROR, "mux %p err %d\n", m, err); - spin_lock_irqsave(&m->client->lock, flags); + spin_lock(&m->client->lock); if (m->err) { - spin_unlock_irqrestore(&m->client->lock, flags); + spin_unlock(&m->client->lock); return; } @@ -217,7 +216,7 @@ static void p9_conn_cancel(struct p9_conn *m, int err) list_for_each_entry_safe(req, rtmp, &m->unsent_req_list, req_list) { list_move(&req->req_list, &cancel_list); } - spin_unlock_irqrestore(&m->client->lock, flags); + spin_unlock(&m->client->lock); list_for_each_entry_safe(req, rtmp, &cancel_list, req_list) { p9_debug(P9_DEBUG_ERROR, "call back req %p\n", req); --