Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1229531pxj; Fri, 4 Jun 2021 09:06:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWLjZ9Xco1bh9TiF8J0+e7B8A9OFBlZgJac8CvaIP855hEg7J+B+H82jvF23bz1e7vSQJa X-Received: by 2002:a17:907:7749:: with SMTP id kx9mr5049175ejc.90.1622822815074; Fri, 04 Jun 2021 09:06:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622822815; cv=none; d=google.com; s=arc-20160816; b=Y+f01THYMkbx3+B0cWF3hgdTMuXRxaJctmbkKmIhAsedUusmPNUXgYDyOsJz/FG0pA ojoQjW7vDeBDdZtj6yez7ONBFcIzY/ERRxJXwB3+cNHK/vri52QAaFYTiHLlJkuL5E2t f3fygJpJ66nROEokQ/iW1rsIo1ajrmffPm6uiSZrJE9HkgpnmaMoRK1dmisokga/H3dN fU5B6dkN4r0+zITIoEwx7NEHz2qc3jys1zSQxtxbgYFmjDjlJzlSQ/Ct77Xwo6+uaCE+ ufJYSoy9crruLm44m7ipxZkqnpn6og4OLvBEIXn8xQlRR++0sdYHZuQBTE66TBFlYB49 kqHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=HQgY2UlrVcVUwXmLsUPhngJNCXjshs/i0MSGjqQ52WM=; b=e5IY9vnNlUT8Fg+Hs/HZR1XBiqrXaXHdVijMB2wTrOSoGH/ojG2Qx6nboxNSQVnloQ 9z83Y4/CIjMmYsKtnKqvUShYTwuBjKeSyio5i1dzrrL1+VzL5uI5quBym7c/oePvS0t1 jyXymmoJ2u3pbVWWyop0M8UGQuSydDzdJ3IaxbcDuKlTN543rknmDP6b395EWs1khm0v tJZ2/k+jq2xq7khaiT0SQeObsUTwq5PF93z+//s1zjruDp15qZ4OybXVJ8SFvNqUJefv q36fI6/H6teCYOhsKFGPCFRWhdh8MGTvwJIN77v2jkGg0E5VAgSHKCjakmz+XxkfqllZ hdPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ccGAmJcT; 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 v22si5074349ejc.505.2021.06.04.09.06.30; Fri, 04 Jun 2021 09:06:55 -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=ccGAmJcT; 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 S230377AbhFDQG7 (ORCPT + 99 others); Fri, 4 Jun 2021 12:06:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44815 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229924AbhFDQG6 (ORCPT ); Fri, 4 Jun 2021 12:06:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622822711; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HQgY2UlrVcVUwXmLsUPhngJNCXjshs/i0MSGjqQ52WM=; b=ccGAmJcTrnupihjSIHsRtii49r+Fx0k2UQsFQazl/ypD1Wz/Tw1FC6WiotLuBsmkGrQlt7 +rNzZCN4LZC8B6Z1cph222bJrTWdFN7FZDC/tfq1bOL1h+tJiVIBTlHvcXv34y1Ln/wVV9 J8zl7+pIBoYkPwnMg6BtQ3q4srtSfKA= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-242-V-VgABEbO5OrAhM93tTPGA-1; Fri, 04 Jun 2021 12:05:10 -0400 X-MC-Unique: V-VgABEbO5OrAhM93tTPGA-1 Received: by mail-ed1-f71.google.com with SMTP id dd28-20020a056402313cb029038fc9850034so5224414edb.7 for ; Fri, 04 Jun 2021 09:05:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=HQgY2UlrVcVUwXmLsUPhngJNCXjshs/i0MSGjqQ52WM=; b=Dm9r9ND4e39NzLpJmnrqEbtXxPOYPwn8/OEJgCCdgp/V3KJOw2efwtXfACLdFSmS8F i57y/lSNGloLQ/blMACHbm5GIG5NKHGdYKtcckYgdQE/dvlhPrMDUVufBKZHfb0rKFc1 pedSoVB8sXNDVtxqacGCCNc/fSpCjMF2VFyPAs+4o3uCIbDfqXVAVW3ZdSo4NurfSV/x hT3Y5Q9nRGSP/9TEH8EtNkanbu+2oaY6tN8WIga1W6y2YUsxU60U1VPUCeA8cOebucxV 9YVB5m9GvnsXc/vEumVnP8dAMS8PE0rRoi3GEjBb8UNYNuFgoSWMe+gUpMHw++PRS4ZN tqeQ== X-Gm-Message-State: AOAM533wUcmzaV6K0arKZrOWLrpIgCKe7CUYIPNiHQY6c35PWCsR4h7P m0+nDfGIO6j0Il4f8EY66hGpyWRd2PFELSH3I4wTqpNzVbbfKIoFVjISIwe1DkJ9drvkvrhg9jy RhVCxgvFOt5Srj0d6PrO4SoDj X-Received: by 2002:a17:906:b048:: with SMTP id bj8mr4886122ejb.236.1622822708435; Fri, 04 Jun 2021 09:05:08 -0700 (PDT) X-Received: by 2002:a17:906:b048:: with SMTP id bj8mr4886097ejb.236.1622822708284; Fri, 04 Jun 2021 09:05:08 -0700 (PDT) Received: from x1.bristot.me (host-79-24-6-4.retail.telecomitalia.it. [79.24.6.4]) by smtp.gmail.com with ESMTPSA id r2sm2899653ejc.78.2021.06.04.09.05.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jun 2021 09:05:07 -0700 (PDT) Subject: Re: [PATCH V3 5/9] tracing/trace: Add a generic function to read/write u64 values from tracefs To: Steven Rostedt Cc: linux-kernel@vger.kernel.org, Phil Auld , Sebastian Andrzej Siewior , Kate Carcia , Jonathan Corbet , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , Alexandre Chartre , Clark Willaims , John Kacur , Juri Lelli , linux-doc@vger.kernel.org References: <20210603172244.6d2a6059@gandalf.local.home> From: Daniel Bristot de Oliveira Message-ID: Date: Fri, 4 Jun 2021 18:05:06 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210603172244.6d2a6059@gandalf.local.home> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/3/21 11:22 PM, Steven Rostedt wrote: > On Fri, 14 May 2021 22:51:14 +0200 > Daniel Bristot de Oliveira wrote: > >> Provides a generic read and write implementation to save/read u64 values >> from a file on tracefs. The trace_ull_config structure defines where to >> read/write the value, the min and the max acceptable values, and a lock >> to protect the write. > > This states what the patch is doing, but does not say why it is doing it. Yeah... >> >> Cc: Jonathan Corbet >> Cc: Steven Rostedt >> Cc: Ingo Molnar >> Cc: Peter Zijlstra >> Cc: Thomas Gleixner >> Cc: Alexandre Chartre >> Cc: Clark Willaims >> Cc: John Kacur >> Cc: Juri Lelli >> Cc: linux-doc@vger.kernel.org >> Cc: linux-kernel@vger.kernel.org >> Signed-off-by: Daniel Bristot de Oliveira >> --- >> kernel/trace/trace.c | 87 ++++++++++++++++++++++++++++++++++++++++++++ >> kernel/trace/trace.h | 19 ++++++++++ >> 2 files changed, 106 insertions(+) >> >> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c >> index 560e4c8d3825..b4cd89010813 100644 >> --- a/kernel/trace/trace.c >> +++ b/kernel/trace/trace.c >> @@ -7516,6 +7516,93 @@ static const struct file_operations snapshot_raw_fops = { >> >> #endif /* CONFIG_TRACER_SNAPSHOT */ >> >> +/* >> + * trace_ull_config_write - Generic write function to save u64 value > > > That is a horrible name. What the hell is the "config"? > >> + * @filp: The active open file structure >> + * @ubuf: The userspace provided buffer to read value into >> + * @cnt: The maximum number of bytes to read >> + * @ppos: The current "file" position >> + * >> + * This function provides a generic write implementation to save u64 values >> + * from a file on tracefs. The filp->private_data must point to a >> + * trace_ull_config structure that defines where to write the value, the >> + * min and the max acceptable values, and a lock to protect the write. > > This doesn't seem to be a generic way to save 64 bit values (which I still > don't understand, because unsigned long long should work too). But it looks > like the rational is for having some kind of generic way to read 64 bit > values giving them a min and a max. > > I see this is used later, but this patch needs to be rewritten. It makes no > sense. The reason for this patch is that hwlat, osnoise, and timerlat have "u64 config" options that are read/write via tracefs "files." In the previous version, I had multiple functions doing basically the same thing: A write function that: read a u64 from user-space get a lock, check for min/max acceptable values save the value release the lock. and a read function that: write the config value to the "read" buffer. And so, I tried to come up with a way to avoid code duplication. question: are only the names that are bad? (I agree that they are bad) or do you think that the overall idea is bad? :-) Suggestions? -- Daniel > -- Steve