Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp520203ybk; Wed, 20 May 2020 05:39:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOGPklCYmf5vfmhEICHTYa2kqzDsY3q/bmkuDmDT1F01GYTy8UMj9Sazb2QAlnWwe70aZ0 X-Received: by 2002:a05:6402:1d98:: with SMTP id dk24mr3060459edb.206.1589978399408; Wed, 20 May 2020 05:39:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589978399; cv=none; d=google.com; s=arc-20160816; b=RxIj77XgbI97xTy79ahigGq7i0m8tXHDRzNO0BzbGiwMHVV5p2rmuJ+ZbGxmxkTe6Q xeQza2iH5RkhHp250xmoyN2Za63G5h3AySCbGtM0nTni7/51kBWiPT92rWaYiU7exM2I iIemqq0M7gOxmyl56lLvUjmEr1vHXBJbW3N8KgeAkxdkC1LNABwHtkKcjpgYmzob1JA5 p4Qrnp2tzOECwAafwxEebubQtaL7deEoLrzKR+mXMny445B91k3ccBFFiar2Cx0Y/3ej 4OBliBIPymkBvlVYEyfU5qQWORBHX8mY6aif7qN/yexofPLbbXjjrCDVCMzNSc2YjUu9 tA/Q== 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=NhwYEb+DwJrIkmy7L0krdQJinx9f7VmDRd5lenUbKQU=; b=Kmae1mSVWgGa9a1vGxo9VPQTLCAoAn6Yr6KT7tvfOtUJEaGwlw5JQWcOB+dlBPXw2Q +yzXCTDz06aQBrKKA6XtlHberlmPVwg3SvxHjmzlkJeq+p/PX8e0+AkG+aMYWJL4E/UL hsl9AT1fl30nGSH/KTmyzl41mype3ovXxw9iYhMGD6QfqhealnvPWbV2gxVTYHqJN3ha U/C+Vjnr6RZezS2LyMHzuofo1+xqp+JUuPh8hwFh437Bl9njJ4ZdpQCVtwZv3UaNWulp P776gZ3f333sbYdqe7F3jiymf7gM6b0QPfe4QoLYS8ax3/bwd6I9o6NyUMhXMVeGGBjy iOqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=I6Nf2Mwq; 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 w13si1349603edf.228.2020.05.20.05.39.36; Wed, 20 May 2020 05:39:59 -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=I6Nf2Mwq; 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 S1726899AbgETMiR (ORCPT + 99 others); Wed, 20 May 2020 08:38:17 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:47800 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726224AbgETMiQ (ORCPT ); Wed, 20 May 2020 08:38:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589978295; 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=NhwYEb+DwJrIkmy7L0krdQJinx9f7VmDRd5lenUbKQU=; b=I6Nf2MwqXwmloFnmmuqFbqgvqTlQN9ejx5vzcLemF5XNuDS+vLdlwWBs15yPdL79kUyhQx PMOf4YNwjUBxewh5eidkpGVXf/xBn68onGTltcUbI65Q+p6hYX1GFLwjOAtFRuwqOdEC8M 33OkSzTqFSWmk9UA7XT730rrjPXJMbk= 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-256-ZaOicCEfNNGUC0PuVWBLqQ-1; Wed, 20 May 2020 08:38:11 -0400 X-MC-Unique: ZaOicCEfNNGUC0PuVWBLqQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 86C101005510; Wed, 20 May 2020 12:38:10 +0000 (UTC) Received: from krava (unknown [10.40.193.10]) by smtp.corp.redhat.com (Postfix) with SMTP id B4CB019C4F; Wed, 20 May 2020 12:38:08 +0000 (UTC) Date: Wed, 20 May 2020 14:38:07 +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 v3 2/9] perf evlist: implement control command handling functions Message-ID: <20200520123807.GD157452@krava> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 13, 2020 at 11:00:02AM +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, &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); > + 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))) { > + *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; > + } are there more comands comming? jirka