Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3164795imm; Mon, 16 Jul 2018 23:28:25 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcJ/TN4+f13K6jFVQ1Tr2lgv7tEytZeXjTWVB+ZJDi4esQkm/Zne08xTqfRSBOLzCutCGuo X-Received: by 2002:a17:902:e18b:: with SMTP id cd11-v6mr313037plb.305.1531808905715; Mon, 16 Jul 2018 23:28:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531808905; cv=none; d=google.com; s=arc-20160816; b=az+GK1GgTkPIbactVVZ0/+oc9CKrLecXNkF6LGnMn/dEc9/tqjj0e2TwSq00VF3rz+ Ysq4gwLfxQJOJShaIwq3TRNNR8eVD49jFDiTDyW0tAZmLKLw36vrwOSCIwQGsAKI1zxK nwakR+s7EFDmvkZF3SAMDx26DRMpxQCMblyYmE/VBFRltw4E2HKl2zEVLxKbJvSspE/1 xWLZu4ii+AT7veVzf6/GPn3OybxV0Zzz/a4z+I+bz3caPQ3LV81quXcvpeKaJvHTzL6r r4Z/b+CHHAFaYV0kvGjgaRFWGkwpUcSlK9eJQ3gU3LMPW5i4M4JyutmRtVhPSEu/L9wG Nmng== 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=kY118sJJtsNw5OHFCX66T4DjtnTxGCcvTbuVQiWXZww=; b=qrRAZeAV+fojORpaTtLLV+lYUwAhR7TGnh46W383s+wXRts/7WX55SkN3w19JyjE0a 4dXpD9rIiOiRWBoW7UbgJ2b5eiq/JQzE9r6pkH/kI1fI1+JTUJTZNMpVYn2e61DudYfk m66rAUX8zMj/WdcCpagEYdBtFk6nHKHG7nuizg5LNRlxrVNVGts7m4uhPBFYfzwkwYTR vuFiNDOckhc9JNSrQTHhdrTCkHsV/9QL7cWYuGBcZghl0RQIN6nT7VvSp7Hh2ogeAFQi o0MWnSGX19oLsgyKJsEHLr1TOg3RRs1oP4aKoCeo7t9LxbW6QyrjtXnnyT1QwDQsF0D/ DU6w== 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 w16-v6si196672pfj.144.2018.07.16.23.27.47; Mon, 16 Jul 2018 23:28:25 -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 S1729649AbeGQG5A (ORCPT + 99 others); Tue, 17 Jul 2018 02:57:00 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:9630 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728015AbeGQG5A (ORCPT ); Tue, 17 Jul 2018 02:57:00 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 94AF4172FE010; Tue, 17 Jul 2018 14:25:43 +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; Tue, 17 Jul 2018 14:25:40 +0800 To: Dominique Martinet CC: Eric Van Hensbergen , Ron Minnich , Latchesar Ionkov , Linux Kernel Mailing List , From: piaojun Subject: [PATCH v2] net/9p/client.c: fix misuse of spin_lock_irqsave for p9_client lock Message-ID: <5B4D8BD8.3040009@huawei.com> Date: Tue, 17 Jul 2018 14:25:28 +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. Rebased on 9p-next. Signed-off-by: Jun Piao --- net/9p/client.c | 18 ++++++++---------- net/9p/trans_fd.c | 7 +++---- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/net/9p/client.c b/net/9p/client.c index 30f9aee..f6897ee 100644 --- a/net/9p/client.c +++ b/net/9p/client.c @@ -275,14 +275,14 @@ static struct p9_fcall *p9_fcall_alloc(int alloc_msize) INIT_LIST_HEAD(&req->req_list); idr_preload(GFP_NOFS); - spin_lock_irq(&c->lock); + spin_lock(&c->lock); if (type == P9_TVERSION) tag = idr_alloc(&c->reqs, req, P9_NOTAG, P9_NOTAG + 1, GFP_NOWAIT); else tag = idr_alloc(&c->reqs, req, 0, P9_NOTAG, GFP_NOWAIT); req->tc->tag = tag; - spin_unlock_irq(&c->lock); + spin_unlock(&c->lock); idr_preload_end(); if (tag < 0) goto free; @@ -328,13 +328,12 @@ struct p9_req_t *p9_tag_lookup(struct p9_client *c, u16 tag) */ static void p9_free_req(struct p9_client *c, struct p9_req_t *r) { - unsigned long flags; u16 tag = r->tc->tag; p9_debug(P9_DEBUG_MUX, "clnt %p req %p tag: %d\n", c, r, tag); - spin_lock_irqsave(&c->lock, flags); + spin_lock(&c->lock); idr_remove(&c->reqs, tag); - spin_unlock_irqrestore(&c->lock, flags); + spin_unlock(&c->lock); kfree(r->tc); kfree(r->rc); kmem_cache_free(p9_req_cache, r); @@ -846,10 +845,10 @@ static struct p9_fid *p9_fid_create(struct p9_client *clnt) fid->fid = 0; idr_preload(GFP_KERNEL); - spin_lock_irq(&clnt->lock); + spin_lock(&clnt->lock); ret = idr_alloc_u32(&clnt->fids, fid, &fid->fid, P9_NOFID - 1, GFP_NOWAIT); - spin_unlock_irq(&clnt->lock); + spin_unlock(&clnt->lock); idr_preload_end(); if (!ret) @@ -862,13 +861,12 @@ 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; - spin_lock_irqsave(&clnt->lock, flags); + spin_lock(&clnt->lock); idr_remove(&clnt->fids, fid->fid); - 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 bf459ee..94ef685 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); --