From patchwork Wed Aug 29 12:17:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Motai.Hirotaka@aj.MitsubishiElectric.co.jp" X-Patchwork-Id: 10580201 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B1915175A for ; Wed, 29 Aug 2018 12:41:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A06EE2A69C for ; Wed, 29 Aug 2018 12:41:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 94D7A2B00C; Wed, 29 Aug 2018 12:41:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F235F2B00B for ; Wed, 29 Aug 2018 12:41:00 +0000 (UTC) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 94475D23; Wed, 29 Aug 2018 12:36:46 +0000 (UTC) X-Original-To: ltsi-dev@lists.linuxfoundation.org Delivered-To: ltsi-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 67FEAD06 for ; Wed, 29 Aug 2018 12:36:41 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mx04.melco.co.jp (mx04.melco.co.jp [192.218.140.144]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 6AA9B7C2 for ; Wed, 29 Aug 2018 12:36:36 +0000 (UTC) Received: from mr04.melco.co.jp (mr04 [133.141.98.166]) by mx04.melco.co.jp (Postfix) with ESMTP id 60C783A27F8 for ; Wed, 29 Aug 2018 21:17:25 +0900 (JST) Received: from mr04.melco.co.jp (unknown [127.0.0.1]) by mr04.imss (Postfix) with ESMTP id 420l4P2kPpzRkF8 for ; Wed, 29 Aug 2018 21:17:25 +0900 (JST) Received: from mf03_second.melco.co.jp (unknown [192.168.20.183]) by mr04.melco.co.jp (Postfix) with ESMTP id 420l4P2QP2zRjwX for ; Wed, 29 Aug 2018 21:17:25 +0900 (JST) Received: from mf03.melco.co.jp (unknown [133.141.98.183]) by mf03_second.melco.co.jp (Postfix) with ESMTP id 420l4P1xBdzRkCd for ; Wed, 29 Aug 2018 21:17:25 +0900 (JST) Received: from JPN01-OS2-obe.outbound.protection.outlook.com (unknown [23.103.139.149]) by mf03.melco.co.jp (Postfix) with ESMTP id 420l4P1XRZzRk8v for ; Wed, 29 Aug 2018 21:17:25 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mitsubishielectricgroup.onmicrosoft.com; s=selector1-mitsubishielectricgroup-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JXPpf57MHf5al8QJOCeVU8oqMYM6b/aYjTDz9mjPTwU=; b=fh+keLP1d7zYuaE6u3wg1TV9cOZMJV6YctUFOQXdrFj8xUbbiio0A/usWoXV7PpFauBHkr5nrBlhLvO0iwGYjooNAS1xaKUrjUxH4IR20HFaMflN18xL4JFeAoLA8sU3DT0fJ2TkAECNoL2PmP+PSmzIyrzNV+nPZ97iOUzHj0M= Received: from TY1PR01MB1692.jpnprd01.prod.outlook.com (52.133.160.145) by TY1PR01MB1231.jpnprd01.prod.outlook.com (10.174.226.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.17; Wed, 29 Aug 2018 12:17:24 +0000 Received: from TY1PR01MB1692.jpnprd01.prod.outlook.com ([fe80::d04e:e6f6:c782:22fa]) by TY1PR01MB1692.jpnprd01.prod.outlook.com ([fe80::d04e:e6f6:c782:22fa%2]) with mapi id 15.20.1080.015; Wed, 29 Aug 2018 12:17:24 +0000 From: "Motai.Hirotaka@aj.MitsubishiElectric.co.jp" To: "ltsi-dev@lists.linuxfoundation.org" Thread-Topic: [LTSI-dev] [PATCH 08/54] tracing: Break out hist trigger assignment parsing Thread-Index: AdQ/iblxh9wYYV6XQkGA2ih50+jtug== Date: Wed, 29 Aug 2018 12:17:04 +0000 Deferred-Delivery: Wed, 29 Aug 2018 12:15:00 +0000 Message-ID: Accept-Language: ja-JP, en-US Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: x-melpop: 1 authentication-results: spf=none (sender IP is ) smtp.mailfrom=Motai.Hirotaka@aj.MitsubishiElectric.co.jp; x-originating-ip: [153.231.200.201] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; TY1PR01MB1231; 6:XVck0euWSv+CB8ibP+5ZsdFk3WCSJPdhjhADk/wapUrybkIkNo4WsUA1Er0t71qvKb3u54x9KVpknAKpOzqd5swYagvfV+JlFI/4RrOAxrsOKVnxMVP0AynMc+Fw+3/EHx2xHSa5InvxqGZFU13pLWadM35Mzxprga8e37Ihqeh+qH2M202s6wUx8vzwsygwjLpYBL96gxK3ERZpQqUTddm5aFHb7mUv1TFzyJFNM1TNoP5lWdkdUNGmh9qM7xf4GmFCV8dh/GERZXgKTmT5Z1wK5SqWRfelvoP+NDajaiDmmntDBfoaqIIcuKE7JgUw6ihrfksYuRu5hFL5HFJZpDog3EzWobmNduvIdpDUJtr5sQQTatMsdDYpuNNZWG6OrD9ED/3KzQfRBdBHfNPGr1vMkQQcU6f9kg73XRslBlr52HUKmfLMhFIIhemDEAvoEjQu+Dd0dJi8IiCVNXmHLw==; 5:Wx4+B4c/hFhQ8l3h5nD/DKlbmZ29LR2sfVOWZRLz9rD4QOsolbHnS2/XACOOvHAjnW/z/N7iMfLABp1Dvx/9lzhL2xndfZhLPM96/A5EPII9HRjnNjSFy6Ekze7Ro87qIH27lu1cXRFpF8yaWvato6RyAkPc5KduuaLEWGNtjHI=; 7:WoFZm3Nez+ZknnfElOfGYuw36dVeBlwYqu63IM2RhG8AtA64PmH4ukq/UqeHeZCPbyWeYBipAwM2vvlu6yzjESmXnIliIwjX6AAsgmf0ZIGcBXqMAbSDwB1O1ksykDK7+eyWkJ8foRlrBciXekXgp+OPgXpJEM4BAM5txAInUbXmOnAaQo8U6YSUqw1Kxco4swwAs+EVNj8rR/FsmwH9++pTLOSzMb8dVjX5/ReTJrHam/tKKHnsJqHqcN1qCrXn x-ms-office365-filtering-correlation-id: 51ec3658-0325-4639-28bd-08d60da96101 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:TY1PR01MB1231; x-ms-traffictypediagnostic: TY1PR01MB1231: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(42068640409301)(228905959029699); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(10201501046)(3231311)(944501410)(52105095)(149027)(150027)(6041310)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(201708071742011)(7699016); SRVR:TY1PR01MB1231; BCL:0; PCL:0; RULEID:; SRVR:TY1PR01MB1231; x-forefront-prvs: 077929D941 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(396003)(366004)(376002)(346002)(39860400002)(189003)(199004)(478600001)(105586002)(2906002)(14454004)(33656002)(66066001)(966005)(72206003)(6116002)(3846002)(97736004)(2900100001)(2501003)(5250100002)(74482002)(25786009)(7736002)(9686003)(5660300001)(6506007)(26005)(6666003)(6916009)(2351001)(81156014)(106356001)(86362001)(6436002)(6306002)(5640700003)(74316002)(8676002)(1857600001)(81166006)(102836004)(53936002)(7696005)(68736007)(55016002)(305945005)(256004)(316002)(186003)(8936002)(486006)(99286004)(476003); DIR:OUT; SFP:1102; SCL:1; SRVR:TY1PR01MB1231; H:TY1PR01MB1692.jpnprd01.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:0; received-spf: None (protection.outlook.com: aj.MitsubishiElectric.co.jp does not designate permitted sender hosts) x-microsoft-antispam-message-info: SZ7leCHqSBB7MCS0EbcZmPgfwZ7olWnKwqruejVa1UmqY9TFH3j07GfqRN0p2DL1zr9/MKmFQiXNWmInwBCKGhN6dLheBidiJqViG8XhzsyiCJzu5CW+L2eXv282192b/Po4C1vwzaG/XDxV4b6ahL7Yd+7bx6FSQIb4bHc1eJ/v88kEa7Uq5ImLNvh6ZbTul0I0BwctOrEheohMCaen3UlYcqbf1Oh5WOmMUOI6fNCG9O1V4te4AbJj7+N8RJkEicCk9GwNG+Ka7OGFvLOhsi7ifJocOzeITliJZagNMLuwTA8qGcgPo2LhZ8ROGj2C8sgBFtif4xL+/hablcomCcOh9o1qy/yMNAVXBVq/R3o= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aj.MitsubishiElectric.co.jp X-MS-Exchange-CrossTenant-Network-Message-Id: 51ec3658-0325-4639-28bd-08d60da96101 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Aug 2018 12:17:22.6277 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: c5a75b62-4bff-4c96-a720-6621ce9978e5 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY1PR01MB1231 Subject: [LTSI-dev] [PATCH 08/54] tracing: Break out hist trigger assignment parsing X-BeenThere: ltsi-dev@lists.linuxfoundation.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: "A list to discuss patches, development, and other things related to the LTSI project" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ltsi-dev-bounces@lists.linuxfoundation.org Errors-To: ltsi-dev-bounces@lists.linuxfoundation.org X-Virus-Scanned: ClamAV using ClamSMTP This will make it easier to add variables, and makes the parsing code cleaner regardless. Link: http://lkml.kernel.org/r/e574b3291bbe15e35a4dfc87e5395aa715701c98.1516069914.git.tom.zanussi@linux.intel.com Signed-off-by: Tom Zanussi Signed-off-by: Rajvi Jingar Signed-off-by: Steven Rostedt (VMware) (cherry picked from commit 9b1ae035c9304ed1e183de3b3bb08eafd01a7553) Signed-off-by: Hirotaka MOTAI --- kernel/trace/trace_events_hist.c | 72 ++++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 21 deletions(-) diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index 37f5acef..e4368bb7 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -246,55 +246,85 @@ static void destroy_hist_trigger_attrs(struct hist_trigger_attrs *attrs) kfree(attrs->name); kfree(attrs->sort_key_str); kfree(attrs->keys_str); kfree(attrs->vals_str); kfree(attrs); } +static int parse_assignment(char *str, struct hist_trigger_attrs *attrs) +{ + int ret = 0; + + if ((strncmp(str, "key=", strlen("key=")) == 0) || + (strncmp(str, "keys=", strlen("keys=")) == 0)) { + attrs->keys_str = kstrdup(str, GFP_KERNEL); + if (!attrs->keys_str) { + ret = -ENOMEM; + goto out; + } + } else if ((strncmp(str, "val=", strlen("val=")) == 0) || + (strncmp(str, "vals=", strlen("vals=")) == 0) || + (strncmp(str, "values=", strlen("values=")) == 0)) { + attrs->vals_str = kstrdup(str, GFP_KERNEL); + if (!attrs->vals_str) { + ret = -ENOMEM; + goto out; + } + } else if (strncmp(str, "sort=", strlen("sort=")) == 0) { + attrs->sort_key_str = kstrdup(str, GFP_KERNEL); + if (!attrs->sort_key_str) { + ret = -ENOMEM; + goto out; + } + } else if (strncmp(str, "name=", strlen("name=")) == 0) { + attrs->name = kstrdup(str, GFP_KERNEL); + if (!attrs->name) { + ret = -ENOMEM; + goto out; + } + } else if (strncmp(str, "size=", strlen("size=")) == 0) { + int map_bits = parse_map_size(str); + + if (map_bits < 0) { + ret = map_bits; + goto out; + } + attrs->map_bits = map_bits; + } else + ret = -EINVAL; + out: + return ret; +} + static struct hist_trigger_attrs *parse_hist_trigger_attrs(char *trigger_str) { struct hist_trigger_attrs *attrs; int ret = 0; attrs = kzalloc(sizeof(*attrs), GFP_KERNEL); if (!attrs) return ERR_PTR(-ENOMEM); while (trigger_str) { char *str = strsep(&trigger_str, ":"); - if ((strncmp(str, "key=", strlen("key=")) == 0) || - (strncmp(str, "keys=", strlen("keys=")) == 0)) - attrs->keys_str = kstrdup(str, GFP_KERNEL); - else if ((strncmp(str, "val=", strlen("val=")) == 0) || - (strncmp(str, "vals=", strlen("vals=")) == 0) || - (strncmp(str, "values=", strlen("values=")) == 0)) - attrs->vals_str = kstrdup(str, GFP_KERNEL); - else if (strncmp(str, "sort=", strlen("sort=")) == 0) - attrs->sort_key_str = kstrdup(str, GFP_KERNEL); - else if (strncmp(str, "name=", strlen("name=")) == 0) - attrs->name = kstrdup(str, GFP_KERNEL); - else if (strcmp(str, "pause") == 0) + if (strchr(str, '=')) { + ret = parse_assignment(str, attrs); + if (ret) + goto free; + } else if (strcmp(str, "pause") == 0) attrs->pause = true; else if ((strcmp(str, "cont") == 0) || (strcmp(str, "continue") == 0)) attrs->cont = true; else if (strcmp(str, "clear") == 0) attrs->clear = true; - else if (strncmp(str, "size=", strlen("size=")) == 0) { - int map_bits = parse_map_size(str); - - if (map_bits < 0) { - ret = map_bits; - goto free; - } - attrs->map_bits = map_bits; - } else { + else { ret = -EINVAL; goto free; } } if (!attrs->keys_str) { ret = -EINVAL; goto free;