Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp589795ybt; Wed, 24 Jun 2020 06:38:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnju0500LHQtLj6evK0WWml8Ol8EGr/lb7bSer1Eq3sF+vdiiKgwaPHtFyflZJ49/KqpA7 X-Received: by 2002:aa7:d14c:: with SMTP id r12mr3991890edo.58.1593005934283; Wed, 24 Jun 2020 06:38:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593005934; cv=none; d=google.com; s=arc-20160816; b=IWfWTC6PR0PiWOqcok2MgOgeLcxIj+rXGoulM5CbxNHOznWounlYeKFlJulLjw7UCx 8G7NOsdhZW7JPTgxhZ9AuAhRhmTx6JHKTheyEFWcX3ziFph27PjGpEcW4dfYKQgAk8Ff GNC+TpemsBsGVzmndlSdfljSzPiJXO7uMmXwYhEAwL8UDBjxskO2pH0hgNaPpEstKhjd thmMe7r2Xbl2vIH/wz0n+WfGAHZppfvHHjDiBmCg2UuluPynKsvcuPct6naGt34d7+H+ DvwGJ5pN0/spPFTHc2mZ+2DxgKkDiCd+FeMQHG2IHz9wX52oTQmB7o8iq/8YBzI0Iduu iG8Q== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject:ironport-sdr :ironport-sdr; bh=RinbGaXBKUXH+eiW15J4coGVf5zpxMRCS/W8hR/6GX4=; b=dNA5sZaqWmYmq9gwmudy1rC+sMh9U+Qs6zzCrskf6CJ/MgG+LOMSVj/TYS2Yvf8I9n cUKtDZ/tnWT9+GbtvQzRhixkn2rIotPDsUrIzDhE/QSPgRcCbR0K099rsUQh+EXbhBZe 6wqH9okqco+CrsfyPQWf3RMw+IxCHpAxBHb4bGwQWoy1/WDc2cp/UlXoYp5Pw1tNkCzQ l1mIFczCtsB3Odwfy+3lud/kp8Mn0EcmyNwBzv9h6Ifq3qhx3uMyAzv37AspXizJh+Ed 37y06y1hngZ7my4LbJ2KKKVMI1cmoxl67435CLNo7LMHiE44lEY+CJ2GlNnJRQV9GI42 nkBQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l30si15326423edj.499.2020.06.24.06.38.31; Wed, 24 Jun 2020 06:38:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391062AbgFXNfF (ORCPT + 99 others); Wed, 24 Jun 2020 09:35:05 -0400 Received: from mga17.intel.com ([192.55.52.151]:37153 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389340AbgFXNfF (ORCPT ); Wed, 24 Jun 2020 09:35:05 -0400 IronPort-SDR: NmzMXEqMeja3felCToR0TENhMLxe36J9XVwuX7uckWYXQVTNpl3lEjrXsZCFVg3nS4QuNLmDxp 7/qjCrobM/Dw== X-IronPort-AV: E=McAfee;i="6000,8403,9661"; a="124726953" X-IronPort-AV: E=Sophos;i="5.75,275,1589266800"; d="scan'208";a="124726953" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jun 2020 06:35:05 -0700 IronPort-SDR: iiqLHgkY5cruYRbEYUSVOFq+ZhhN6jmmZlefY03zrPEtBmdjIkBlSOo+B2DIzSyekFVMLTsASb nNksj6W4j0wA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,275,1589266800"; d="scan'208";a="311643064" Received: from linux.intel.com ([10.54.29.200]) by fmsmga002.fm.intel.com with ESMTP; 24 Jun 2020 06:35:04 -0700 Received: from [10.249.228.248] (abudanko-mobl.ccr.corp.intel.com [10.249.228.248]) by linux.intel.com (Postfix) with ESMTP id 021B05805B5; Wed, 24 Jun 2020 06:35:02 -0700 (PDT) Subject: Re: [PATCH v8 03/13] perf evlist: implement control command handling functions To: Jiri Olsa , Arnaldo Carvalho de Melo Cc: Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Andi Kleen , linux-kernel References: <0781a077-aa82-5b4a-273e-c17372a72b93@linux.intel.com> <20200623145601.GH2619137@krava> <20200623150345.GA26230@kernel.org> <20200623151442.GL2619137@krava> From: Alexey Budankov Organization: Intel Corp. Message-ID: <9343aea5-7e89-5319-ad44-87aefa5935cd@linux.intel.com> Date: Wed, 24 Jun 2020 16:35:02 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200623151442.GL2619137@krava> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 23.06.2020 18:14, Jiri Olsa wrote: > On Tue, Jun 23, 2020 at 12:03:45PM -0300, Arnaldo Carvalho de Melo wrote: >> Em Tue, Jun 23, 2020 at 04:56:01PM +0200, Jiri Olsa escreveu: >>> On Wed, Jun 17, 2020 at 11:36:46AM +0300, Alexey Budankov wrote: >>> >>> SNIP >>> >>>> + memset(cmd_data, 0, data_size--); >>>> + >>>> + do { >>>> + err = read(evlist->ctl_fd.fd, &c, 1); >>>> + if (err > 0) { >>>> + if (c == '\n' || c == '\0') >>>> + break; >>>> + cmd_data[bytes_read++] = c; >>>> + if (bytes_read == data_size) >>>> + break; >>>> + } else { >>>> + if (err == -1) >>>> + pr_err("Failed to read from ctlfd %d: %m\n", evlist->ctl_fd.fd); >>>> + break; >>>> + } >>>> + } while (1); >>>> + >>>> + pr_debug("Message from ctl_fd: \"%s%s\"\n", cmd_data, >>>> + bytes_read == data_size ? "" : c == '\n' ? "\\n" : "\\0"); >>>> + >>>> + if (err > 0) { >>>> + if (!strncmp(cmd_data, EVLIST_CTL_CMD_ENABLE_TAG, >>>> + strlen(EVLIST_CTL_CMD_ENABLE_TAG))) { >>> >>> you could use sizeof(EVLIST_CTL_CMD_ENABLE_TAG) instead, no function call >> >> -1, as sizeof will get the \0, right? > > yep, I think that's right Ok, let's have it like (sizeof(EVLIST_CTL_CMD_ENABLE_TAG)-1). ~Alexey > > jirka > >> >>> >>>> + *cmd = EVLIST_CTL_CMD_ENABLE; >>>> + } else if (!strncmp(cmd_data, EVLIST_CTL_CMD_DISABLE_TAG, >>>> + strlen(EVLIST_CTL_CMD_DISABLE_TAG))) { >>> >>> ditto >>> >>> jirka >>> >> >> -- >> >> - Arnaldo >> >