From patchwork Tue May 10 00:22:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaohua Li X-Patchwork-Id: 9052671 Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 037FC9F6FA for ; Tue, 10 May 2016 00:22:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 033D6200FE for ; Tue, 10 May 2016 00:22:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1F10C2010E for ; Tue, 10 May 2016 00:22:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753195AbcEJAWo (ORCPT ); Mon, 9 May 2016 20:22:44 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:24495 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753924AbcEJAWU (ORCPT ); Mon, 9 May 2016 20:22:20 -0400 Received: from pps.filterd (m0001303.ppops.net [127.0.0.1]) by m0001303.ppops.net (8.16.0.11/8.16.0.11) with SMTP id u4A0LnTq022553 for ; Mon, 9 May 2016 17:22:19 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=IbjEC6Ujd2YLzJqZ1jtL/mLesWnq5kN/s7gjgPB3crI=; b=CQghr/qMlRUrmYQuys8nmvBVB7DmvAE2a165jXPKvkER9wKPLlLo4S7CHFoAfGZ6eGay OOvn7kXvhzgqPOY7e4cCLihBNjgcbp0BDZ+Q7p/8PK6661zvoGdvc6YvtwVXOcROMH1E A8wwwCfV/Bz7XgHJW3QICvYsMuubC7VjqIg= Received: from mail.thefacebook.com ([199.201.64.23]) by m0001303.ppops.net with ESMTP id 22u4gm04dw-1 (version=TLSv1 cipher=AES128-SHA bits=128 verify=NOT) for ; Mon, 09 May 2016 17:22:19 -0700 Received: from mx-out.facebook.com (192.168.52.123) by PRN-CHUB08.TheFacebook.com (192.168.16.18) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 9 May 2016 17:22:18 -0700 Received: from facebook.com (2401:db00:11:d0a2:face:0:39:0) by mx-out.facebook.com (10.223.101.97) with ESMTP id 40166f6a164511e68ba924be0595f910-ce7d6c50 for ; Mon, 09 May 2016 17:22:16 -0700 Received: by devbig084.prn1.facebook.com (Postfix, from userid 11222) id D795E49C0A28; Mon, 9 May 2016 17:22:15 -0700 (PDT) From: Shaohua Li To: , CC: Steven Rostedt , , Subject: [PATCH 3/3] blk-throttle: don't parse cgroup path if trace isn't enabled Date: Mon, 9 May 2016 17:22:15 -0700 Message-ID: X-Mailer: git-send-email 2.8.0.rc2 In-Reply-To: <2c3ee532132f8925dd0be1178e8dee0bba6b448c.1462838969.git.shli@fb.com> References: <2c3ee532132f8925dd0be1178e8dee0bba6b448c.1462838969.git.shli@fb.com> X-FB-Internal: Safe MIME-Version: 1.0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-05-09_09:, , signatures=0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable 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 trace isn't enabled, parsing cgroup path just wastes cpu Signed-off-by: Shaohua Li --- block/blk-throttle.c | 5 ++--- include/linux/blktrace_api.h | 9 +++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/block/blk-throttle.c b/block/blk-throttle.c index 2149a1d..47a3e54 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -211,15 +211,14 @@ static struct throtl_data *sq_to_td(struct throtl_service_queue *sq) * * The messages are prefixed with "throtl BLKG_NAME" if @sq belongs to a * throtl_grp; otherwise, just "throtl". - * - * TODO: this should be made a function and name formatting should happen - * after testing whether blktrace is enabled. */ #define throtl_log(sq, fmt, args...) do { \ struct throtl_grp *__tg = sq_to_tg((sq)); \ struct throtl_data *__td = sq_to_td((sq)); \ \ (void)__td; \ + if (likely(!blk_trace_note_message_enabled(__td->queue))) \ + break; \ if ((__tg)) { \ char __pbuf[128]; \ \ diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h index afc1343..0f3172b 100644 --- a/include/linux/blktrace_api.h +++ b/include/linux/blktrace_api.h @@ -57,6 +57,14 @@ void __trace_note_message(struct blk_trace *, const char *fmt, ...); } while (0) #define BLK_TN_MAX_MSG 128 +static inline bool blk_trace_note_message_enabled(struct request_queue *q) +{ + struct blk_trace *bt = q->blk_trace; + if (likely(!bt)) + return false; + return bt->act_mask & BLK_TC_NOTIFY; +} + extern void blk_add_driver_data(struct request_queue *q, struct request *rq, void *data, size_t len); extern int blk_trace_setup(struct request_queue *q, char *name, dev_t dev, @@ -79,6 +87,7 @@ extern struct attribute_group blk_trace_attr_group; # define blk_trace_remove(q) (-ENOTTY) # define blk_add_trace_msg(q, fmt, ...) do { } while (0) # define blk_trace_remove_sysfs(dev) do { } while (0) +# define blk_trace_note_message_enabled(q) (false) static inline int blk_trace_init_sysfs(struct device *dev) { return 0;