Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3666548ybt; Tue, 23 Jun 2020 07:58:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEw3cyoA7KZdSzM/rY92IWfkTXbziXudIgNcs2GHdZVS3hS7zQo/0kq51genh3cMHmUPam X-Received: by 2002:a50:b964:: with SMTP id m91mr23350850ede.37.1592924334038; Tue, 23 Jun 2020 07:58:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592924334; cv=none; d=google.com; s=arc-20160816; b=S82/V5HH1X5UQKnfBgXHGWCjU7QmWJAAnU+PBDTD92WGhwOHu0m79BnEVI7gvXIXUD WBiyPbjzPRife5XpAzVq9ow53iySqxxQ8Guo4rDUL16AkHSWT+XbM8qHytEDfVq3mcFt MYkfIo9bXytSCOQUk/Bdzz9pa0KXvyKnrhNYNCPtPH5f6NakCKq8eF7WgoDZFSXUmazT FzKwm7ux2F9R2YyBjKUnW3f55PxySoe2wtuUuhejgcIceHfKBN5t9TD0D0EeHVu2lEd2 Nu+1hCr261wedTTod3l0/u/DXxBUqLlKFGCD1uZoD7qyksDNMpAi6QVCLWUbxHS3qiqK CEQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=HWZ8wEpT9WswtfFYl1mP0fDjlJkStWexSarfhsNNRC0=; b=FUPBgEwhs0brLZYxVSQZPkZlwQpqQ25mtamQE43+3hdnfa+RSHTSBSAz9h6beT0qXf eYt+mYeaYrYcbQVwjc/lpEBNf/8xmJn3jTIJaqnenARLxGGJzBHjJ0hWSfz3Bl8CMV+o Myv8By1NH+lQ1+5ANtRMI3WrcJbnF5w+x33VLlCx6NqV6a3xwsSQ6NKLWCHQCkfsieY1 dA8BmCkZJV9JhB/EldF9n85rDQ3MpV7l1X/UH4yhLdArqoslNPNBQtyrGwG/Z+xzNybc zqL27JsN5dWd0oOa8gRMcOamF7oUW2XLdxRKYSyDbt+gOoJSOtVImT5tzczNeH7pEzNz vwkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MytTFs78; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v8si5536806ejb.548.2020.06.23.07.58.31; Tue, 23 Jun 2020 07:58: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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MytTFs78; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732955AbgFWO4X (ORCPT + 99 others); Tue, 23 Jun 2020 10:56:23 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:22116 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732738AbgFWO4W (ORCPT ); Tue, 23 Jun 2020 10:56:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592924181; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=HWZ8wEpT9WswtfFYl1mP0fDjlJkStWexSarfhsNNRC0=; b=MytTFs78qblUUAb3LS1o1IE2e0poK3sc874kg/TAWtmipF3gXHW5hbhMT2/XWwKFJRQ1qV R1CenIMCh8Gp4XCxAG6JY35fEFDGDMR5gemAk3Lf7Xe40FOn7A5+gszjBUWM4pjLeZxnh6 8FULF18pNo+8+1souc3RLp2dwg9MmtM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-89-DnVl22kUO86pHT5MRq57aQ-1; Tue, 23 Jun 2020 10:56:17 -0400 X-MC-Unique: DnVl22kUO86pHT5MRq57aQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E88FD801503; Tue, 23 Jun 2020 14:56:15 +0000 (UTC) Received: from krava (unknown [10.40.192.77]) by smtp.corp.redhat.com (Postfix) with SMTP id 21FEF7CAA3; Tue, 23 Jun 2020 14:56:13 +0000 (UTC) Date: Tue, 23 Jun 2020 16:56:13 +0200 From: Jiri Olsa To: Alexey Budankov Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Andi Kleen , linux-kernel Subject: Re: [PATCH v8 03/13] perf evlist: implement control command handling functions Message-ID: <20200623145613.GI2619137@krava> References: <0781a077-aa82-5b4a-273e-c17372a72b93@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 17, 2020 at 11:36:46AM +0300, Alexey Budankov wrote: SNIP > +static int evlist__ctlfd_recv(struct evlist *evlist, enum evlist_ctl_cmd *cmd, > + char *cmd_data, size_t data_size) > +{ > + int err; > + char c; > + size_t bytes_read = 0; > + > + 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"); do you want to display the message above only if (err > 0) ? > + > + if (err > 0) { > + if (!strncmp(cmd_data, EVLIST_CTL_CMD_ENABLE_TAG, > + strlen(EVLIST_CTL_CMD_ENABLE_TAG))) { > + *cmd = EVLIST_CTL_CMD_ENABLE; > + } else if (!strncmp(cmd_data, EVLIST_CTL_CMD_DISABLE_TAG, > + strlen(EVLIST_CTL_CMD_DISABLE_TAG))) { > + *cmd = EVLIST_CTL_CMD_DISABLE; > + } > + } > + > + return err; > +} SNIP > + int ctlfd_pos = evlist->ctl_fd.pos; > + struct pollfd *entries = evlist->core.pollfd.entries; > + > + if (ctlfd_pos == -1 || !entries[ctlfd_pos].revents) > + return 0; > + > + if (entries[ctlfd_pos].revents & POLLIN) { > + err = evlist__ctlfd_recv(evlist, cmd, cmd_data, > + EVLIST_CTL_CMD_MAX_LEN); > + if (err > 0) { > + switch (*cmd) { > + case EVLIST_CTL_CMD_ENABLE: > + evlist__enable(evlist); > + break; > + case EVLIST_CTL_CMD_DISABLE: > + evlist__disable(evlist); > + break; > + case EVLIST_CTL_CMD_ACK: > + case EVLIST_CTL_CMD_UNSUPPORTED: > + default: > + pr_debug("ctlfd: unsupported %d\n", *cmd); > + break; > + } > + if (!(*cmd == EVLIST_CTL_CMD_ACK || *cmd == EVLIST_CTL_CMD_UNSUPPORTED)) > + evlist__ctlfd_ack(evlist); > + } > + } > + > + if (entries[ctlfd_pos].revents & (POLLHUP | POLLERR)) > + evlist__finalize_ctlfd(evlist); should this error be propagated via err? jirka