From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0A87C433EF for ; Mon, 29 Nov 2021 14:32:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1870D6B009E; Mon, 29 Nov 2021 09:32:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 10D6B6B00A0; Mon, 29 Nov 2021 09:32:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EC9DD6B00A1; Mon, 29 Nov 2021 09:32:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0234.hostedemail.com [216.40.44.234]) by kanga.kvack.org (Postfix) with ESMTP id D30916B009E for ; Mon, 29 Nov 2021 09:32:48 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 9A7F58631E for ; Mon, 29 Nov 2021 14:32:38 +0000 (UTC) X-FDA: 78862209090.05.0C6560C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf24.hostedemail.com (Postfix) with ESMTP id 0C2CBB000811 for ; Mon, 29 Nov 2021 14:32:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638196351; 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=dJBe9OPhF+PV6aWNoM1mTqTJe8Q2yU80n+V/5mpDDnU=; b=CPjRWjkqqU5JJBDblKPtfhXTeJTJTZ6GHDWsZn0cDkMia/ShJFelw+V+kO8GeSobuKChHM ijgrK22QTVuZ7qWJOcyyxWT+Gt/PbgajRU0wadpV6JludP4KIn80fc5h0/dUoSFiLE+AXx wqeTxQ81MpvTxI44r1YnEM1bS1rO+vQ= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-312-3RUeeRzuOSeuN-9QDslMDw-1; Mon, 29 Nov 2021 09:32:29 -0500 X-MC-Unique: 3RUeeRzuOSeuN-9QDslMDw-1 Received: by mail-wm1-f71.google.com with SMTP id m14-20020a05600c3b0e00b0033308dcc933so10938702wms.7 for ; Mon, 29 Nov 2021 06:32:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:cc:references:from:organization:subject :in-reply-to:content-transfer-encoding; bh=dJBe9OPhF+PV6aWNoM1mTqTJe8Q2yU80n+V/5mpDDnU=; b=kN+0bb2WNwguiU/lKggi1M/N23pubyC2VFbeSIqngxPI0rQXrtNzcU/7nsCf0mRSUE rx8yUCrvu8h/mzlQFiXJlmYR4nkj9Lux0ncsm5bI+sslzCA6Bfq1tuvsV3JQzqpGNt8h d2zAhMN5YxmWYDeUe2lQyxOsF5itcFN+1iZ9qCCR12JKebsJ6UHmlsRJgporqo94m9K2 /QY8VTxLzfzqmtdnxFpTNmB6EwOFJw84uXXhLSLF2H9VRb1+1NrXSCyOqrFXT+MxeK2i uh8r2tlN2C7XWM808gtEbPu89SyujNgMn4aqLLfjs0amdMa3HrITexhMOFNrThSZtDMK 6JFw== X-Gm-Message-State: AOAM530rVLKPY2x3Pqmu8bjrK8IaHDnMuRvqXeZ7M7rFOQiNhmbHMCT6 daBattjaWVTOZ4aoRZ6CYZ40+gCKJR0u93zL4GrJQ192UvQpIzZ+pqykqaImsiTYTg+GcrVT8zY DMW5evlddvVo= X-Received: by 2002:adf:d18f:: with SMTP id v15mr33386196wrc.447.1638196348158; Mon, 29 Nov 2021 06:32:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJyA3jxLgz2qFbocjn5aqKjjz597XHuns2HayZngv2iHRT5zC+cXCqeSgXjkuMRuWEvUCgQECw== X-Received: by 2002:adf:d18f:: with SMTP id v15mr33386167wrc.447.1638196347945; Mon, 29 Nov 2021 06:32:27 -0800 (PST) Received: from [192.168.3.132] (p5b0c6664.dip0.t-ipconnect.de. [91.12.102.100]) by smtp.gmail.com with ESMTPSA id l8sm21215902wmc.40.2021.11.29.06.32.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 29 Nov 2021 06:32:27 -0800 (PST) Message-ID: <54e1b56c-e424-a4b3-4d61-3018aa095f36@redhat.com> Date: Mon, 29 Nov 2021 15:32:26 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 To: Sven Schnelle , Yafang Shao Cc: Andrew Morton , netdev , bpf , "linux-perf-use." , linux-fsdevel@vger.kernel.org, Linux MM , LKML , kernel test robot , kbuild test robot , Andrii Nakryiko , Mathieu Desnoyers , Arnaldo Carvalho de Melo , Andrii Nakryiko , Michal Miroslaw , Peter Zijlstra , Steven Rostedt , Matthew Wilcox , Al Viro , Kees Cook , Petr Mladek References: <20211120112738.45980-1-laoar.shao@gmail.com> <20211120112738.45980-8-laoar.shao@gmail.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH v2 7/7] tools/testing/selftests/bpf: replace open-coded 16 with TASK_COMM_LEN In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 0C2CBB000811 Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CPjRWjkq; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf24.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com X-Stat-Signature: ywsinqaq7f1zp383nmztw1otefsdzp3h X-HE-Tag: 1638196346-794083 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 29.11.21 15:21, Sven Schnelle wrote: > Hi, > > Yafang Shao writes: > >> On Mon, Nov 29, 2021 at 6:13 PM Sven Schnelle wrote: >>>> diff --git a/include/linux/sched.h b/include/linux/sched.h >>>> index 78c351e35fec..cecd4806edc6 100644 >>>> --- a/include/linux/sched.h >>>> +++ b/include/linux/sched.h >>>> @@ -274,8 +274,13 @@ struct task_group; >>>> >>>> #define get_current_state() READ_ONCE(current->__state) >>>> >>>> -/* Task command name length: */ >>>> -#define TASK_COMM_LEN 16 >>>> +/* >>>> + * Define the task command name length as enum, then it can be visible to >>>> + * BPF programs. >>>> + */ >>>> +enum { >>>> + TASK_COMM_LEN = 16, >>>> +}; >>> >>> This breaks the trigger-field-variable-support.tc from the ftrace test >>> suite at least on s390: >>> >>> echo >>> 'hist:keys=next_comm:wakeup_lat=common_timestamp.usecs-$ts0:onmatch(sched.sched_waking).wakeup_latency($wakeup_lat,next_pid,sched.sched_waking.prio,next_comm) >>> if next_comm=="ping"' >>> linux/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-field-variable-support.tc: line 15: echo: write error: Invalid argument >>> >>> I added a debugging line into check_synth_field(): >>> >>> [ 44.091037] field->size 16, hist_field->size 16, field->is_signed 1, hist_field->is_signed 0 >>> >>> Note the difference in the signed field. >>> >> >> Hi Sven, >> >> Thanks for the report and debugging! >> Seems we should explicitly define it as signed ? >> Could you pls. help verify it? >> >> diff --git a/include/linux/sched.h b/include/linux/sched.h >> index cecd4806edc6..44d36c6af3e1 100644 >> --- a/include/linux/sched.h >> +++ b/include/linux/sched.h >> @@ -278,7 +278,7 @@ struct task_group; >> * Define the task command name length as enum, then it can be visible to >> * BPF programs. >> */ >> -enum { >> +enum SignedEnum { >> TASK_COMM_LEN = 16, >> }; > > Umm no. What you're doing here is to define the name of the enum as > 'SignedEnum'. This doesn't change the type. I think before C++0x you > couldn't force an enum type. I think there are only some "hacks" to modify the type with GCC. For example, with "__attribute__((packed))" we can instruct GCC to use the smallest type possible for the defined enum values. I think with some fake entries one can eventually instruct GCC to use an unsigned type in some cases: https://stackoverflow.com/questions/14635833/is-there-a-way-to-make-an-enum-unsigned-in-the-c90-standard-misra-c-2004-compl enum { TASK_COMM_LEN = 16, TASK_FORCE_UNSIGNED = 0x80000000, }; Haven't tested it, though, and I'm not sure if we should really do that ... :) -- Thanks, David / dhildenb