From patchwork Fri Jan 29 06:12:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenbo Wang X-Patchwork-Id: 8159531 Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9FE8ABEEE5 for ; Fri, 29 Jan 2016 06:13:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C1E392037C for ; Fri, 29 Jan 2016 06:13:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 52BF920173 for ; Fri, 29 Jan 2016 06:13:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751485AbcA2GNu (ORCPT ); Fri, 29 Jan 2016 01:13:50 -0500 Received: from m50-132.163.com ([123.125.50.132]:46140 "EHLO m50-132.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751352AbcA2GNt (ORCPT ); Fri, 29 Jan 2016 01:13:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=E15/PV17ezc3lwbgt3 ZgSDopcNr0UkN3IWvIQjZnQL8=; b=PWF3HVNYFNsBrmFCDLo45okhOQ86YsuiDt goJD5mdCmOo8DgUVxXsHRNQMgHuoXGjS4eocMd1onz/TZwt7DlNSCuecjlcDoa6i SSjiUV+OdAXVwMLuV/u3eua2hfaR4t2d+XX+Lauvp10owaydtZS491L9xuRjBpNR Em/fzWsOA= Received: from wenbo.com (unknown [111.204.49.2]) by smtp2 (Coremail) with SMTP id DNGowEDJx1z1AqtWlDi7AA--.6384S2; Fri, 29 Jan 2016 14:13:10 +0800 (CST) From: Wenbo Wang To: axboe@fb.com Cc: sagig@dev.mellanox.co.il, Wenbo Wang , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC] blk-mq: no need to modify bt->wake_index if someone has updated it Date: Fri, 29 Jan 2016 01:12:29 -0500 Message-Id: <1454047949-2747-1-git-send-email-mail_weber_wang@163.com> X-Mailer: git-send-email 1.8.3.1 X-CM-TRANSID: DNGowEDJx1z1AqtWlDi7AA--.6384S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7Aw13WryUCw4xZw4Duw4xCrg_yoW8Jw1Upa yrXa1v9r4aqFy29F4vqa1UAw15CwnrKryUKrZ5J3WYvr9Fkr13W3Wvqrn8Kr10vrZ7C3yU CF47try5GF4UG37anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UOJ5wUUUUU= X-Originating-IP: [111.204.49.2] X-CM-SenderInfo: xpdlzspzhev2xbzd0wi6rwjhhfrp/1tbiNhf+IFWBQqCSxwAAsc Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If someone else has found active waitqueue and updated bt->wake_index, do not modify it again. This saves an atomic read. Signed-off-by: Wenbo Wang CC: linux-block@vger.kernel.org CC: linux-kernel@vger.kernel.org --- block/blk-mq-tag.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c index abdbb47..5ed9111 100644 --- a/block/blk-mq-tag.c +++ b/block/blk-mq-tag.c @@ -356,16 +356,15 @@ unsigned int blk_mq_get_tag(struct blk_mq_alloc_data *data) static struct bt_wait_state *bt_wake_ptr(struct blk_mq_bitmap_tags *bt) { - int i, wake_index; + int i, wake_index, orig_wake_index; - wake_index = atomic_read(&bt->wake_index); + orig_wake_index = wake_index = atomic_read(&bt->wake_index); for (i = 0; i < BT_WAIT_QUEUES; i++) { struct bt_wait_state *bs = &bt->bs[wake_index]; if (waitqueue_active(&bs->wait)) { - int o = atomic_read(&bt->wake_index); - if (wake_index != o) - atomic_cmpxchg(&bt->wake_index, o, wake_index); + if (wake_index != orig_wake_index) + atomic_cmpxchg(&bt->wake_index, orig_wake_index, wake_index); return bs; }