From patchwork Fri Jun 9 03:03:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sunliming X-Patchwork-Id: 13273209 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F412C83005 for ; Fri, 9 Jun 2023 03:04:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237571AbjFIDE0 (ORCPT ); Thu, 8 Jun 2023 23:04:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237892AbjFIDEW (ORCPT ); Thu, 8 Jun 2023 23:04:22 -0400 Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7B4230E8; Thu, 8 Jun 2023 20:04:20 -0700 (PDT) Received: by mail-pf1-f194.google.com with SMTP id d2e1a72fcca58-653f9c7b3e4so1022860b3a.2; Thu, 08 Jun 2023 20:04:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686279860; x=1688871860; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PcKARLPblfhsOqgdK39JcUbv8MjDLZ8IvMWHzSBNScQ=; b=NmRQRMaxM0+7angDvMYYf6yLkZ4m6S9gu+3FQujEUmAoGSOylV6PKKh4c6Rr5Ez0Ny 1ExgMMZLKcL9CadORIpPXlumnAbIvuv5ONAGDtHzrJLy2zEhypmD1W6TMXKmaZ8ji/fI WWNpC10Qzj9NC9zatuV/mWDG8K1OttCaZNgDtqoIoLg8Vssrvr5/8B4Hq5x4Nalcxjp+ EXbfVTPYw/WguXryW26gKXYIwxsoDYzsx3f2Afxz+w8Scx23YXKi64wkshHXbJrrSaLv HuIjjNBG6vGCUYEN4fCbU8RGrGf3EBH20ytxke/lrGB0UciQ+5l1uCoY44kKutqAr5bD b3ug== X-Gm-Message-State: AC+VfDwK6hQWaxghY80Aexe3BgH55bvVUtiDFrSwSRCfFfW8/tAHBfmC vWJC2jD+LBqr5sfogUVWmw== X-Google-Smtp-Source: ACHHUZ65Jiks2flBKktsFvZoSfjAD0b1fcxC3t0e5+cOSXnVdrYpThYCVKd7XmYBGt0YZ8n7EvLKhQ== X-Received: by 2002:a05:6a00:1a4e:b0:662:b5de:27f6 with SMTP id h14-20020a056a001a4e00b00662b5de27f6mr52364pfv.17.1686279860393; Thu, 08 Jun 2023 20:04:20 -0700 (PDT) Received: from localhost.localdomain ([116.128.244.169]) by smtp.gmail.com with ESMTPSA id a16-20020a62bd10000000b0065ecdefa57fsm1713778pff.0.2023.06.08.20.04.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 20:04:20 -0700 (PDT) From: sunliming To: mhiramat@kernel.org, beaub@linux.microsoft.com, rostedt@goodmis.org, shuah@kernel.org Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kelulanainsley@gmail.com, sunliming Subject: [PATCH v2 1/3] tracing/user_events: Fix incorrect return value for writing operation when events are disabled Date: Fri, 9 Jun 2023 11:03:00 +0800 Message-Id: <20230609030302.1278716-2-sunliming@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230609030302.1278716-1-sunliming@kylinos.cn> References: <20230609030302.1278716-1-sunliming@kylinos.cn> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org The writing operation return the count of writes whether events are enabled or disabled. This is incorrect when events are disabled. Fix this by just return -ENOENT when events are disabled. Signed-off-by: sunliming --- kernel/trace/trace_events_user.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c index 1ac5ba5685ed..92204bbe79da 100644 --- a/kernel/trace/trace_events_user.c +++ b/kernel/trace/trace_events_user.c @@ -1957,7 +1957,8 @@ static ssize_t user_events_write_core(struct file *file, struct iov_iter *i) if (unlikely(faulted)) return -EFAULT; - } + } else + return -ENOENT; return ret; } From patchwork Fri Jun 9 03:03:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sunliming X-Patchwork-Id: 13273211 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49E93C7EE29 for ; Fri, 9 Jun 2023 03:05:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238034AbjFIDEp (ORCPT ); Thu, 8 Jun 2023 23:04:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238017AbjFIDEk (ORCPT ); Thu, 8 Jun 2023 23:04:40 -0400 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 042AA3585; Thu, 8 Jun 2023 20:04:29 -0700 (PDT) Received: by mail-pf1-f196.google.com with SMTP id d2e1a72fcca58-652a6bf4e6aso1078029b3a.2; Thu, 08 Jun 2023 20:04:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686279868; x=1688871868; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UwLBYM4w/H7KoFqtcB4hQtAsyswAe46iM2ztf4QLeWA=; b=lROOdt4xdms5cZbvzHzFnZkxK6pVtpJOXC4vWbX4c7myvkCGJlA+QPFHi59nkES2X2 Wuej1GPd9SAJv0szFXo2I11+BhdzoON5OciEEvv09hECo67sslsHkZOP47BnL0++JXCp HEYIUR/hzUYwsXBYLprdQkScF1+EUn2cNLR6Z0I1yJkK1h5tpXrToxt5tWDkmGfHWyfZ qsqiLK5aCbSJiqV/f4EqwVF5fNv5gtMLzbcYYoFrZdgXHy77+b5fd9FuGmOYLZlXuuc/ IZjpIQub6S790/FH+s9JqGVS/q2gpJ8CHBZ7ugq6KhYyjH4nmoip0Dc44+Wvj6Dl+Sqe f3SQ== X-Gm-Message-State: AC+VfDxylAOKg8KNhQj2Xemlhpip4kmZlCzIATCCWHSQTP/GnfUAAOBj GURT6BGgqjhlvF0lcIG8hQ== X-Google-Smtp-Source: ACHHUZ58KmGXkdf1adlVag7X48yeMliPeQiXzcRHoS75t00s7Sq/540FCowE+rKzWZ7O/UJciP7DMg== X-Received: by 2002:a05:6a00:1254:b0:663:83ad:4809 with SMTP id u20-20020a056a00125400b0066383ad4809mr24615pfi.27.1686279868257; Thu, 08 Jun 2023 20:04:28 -0700 (PDT) Received: from localhost.localdomain ([116.128.244.169]) by smtp.gmail.com with ESMTPSA id a16-20020a62bd10000000b0065ecdefa57fsm1713778pff.0.2023.06.08.20.04.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 20:04:27 -0700 (PDT) From: sunliming To: mhiramat@kernel.org, beaub@linux.microsoft.com, rostedt@goodmis.org, shuah@kernel.org Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kelulanainsley@gmail.com, sunliming Subject: [PATCH v2 2/3] selftests/user_events: Enable the event before write_fault test in ftrace self-test Date: Fri, 9 Jun 2023 11:03:01 +0800 Message-Id: <20230609030302.1278716-3-sunliming@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230609030302.1278716-1-sunliming@kylinos.cn> References: <20230609030302.1278716-1-sunliming@kylinos.cn> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org The user_event has not be enabled in write_fault test in ftrace self-test, Just enable it. Signed-off-by: sunliming --- tools/testing/selftests/user_events/ftrace_test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/testing/selftests/user_events/ftrace_test.c b/tools/testing/selftests/user_events/ftrace_test.c index abfb49558a26..d33bd31425db 100644 --- a/tools/testing/selftests/user_events/ftrace_test.c +++ b/tools/testing/selftests/user_events/ftrace_test.c @@ -373,6 +373,10 @@ TEST_F(user, write_fault) { ASSERT_EQ(0, ioctl(self->data_fd, DIAG_IOCSREG, ®)); ASSERT_EQ(0, reg.write_index); + /* Enable event */ + self->enable_fd = open(enable_file, O_RDWR); + ASSERT_NE(-1, write(self->enable_fd, "1", sizeof("1"))) + /* Write should work normally */ ASSERT_NE(-1, writev(self->data_fd, (const struct iovec *)io, 2)); From patchwork Fri Jun 9 03:03:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sunliming X-Patchwork-Id: 13273212 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 356A5C7EE23 for ; Fri, 9 Jun 2023 03:05:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238265AbjFIDFS (ORCPT ); Thu, 8 Jun 2023 23:05:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238228AbjFIDEz (ORCPT ); Thu, 8 Jun 2023 23:04:55 -0400 Received: from mail-ot1-f65.google.com (mail-ot1-f65.google.com [209.85.210.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14A6D30C3; Thu, 8 Jun 2023 20:04:34 -0700 (PDT) Received: by mail-ot1-f65.google.com with SMTP id 46e09a7af769-6b16cbe4fb6so287553a34.1; Thu, 08 Jun 2023 20:04:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686279873; x=1688871873; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ETnK27P5xF7JUmROEHyWwtf42DA9xFAclMKuefb0oy8=; b=cdwAT6tcq0pwv2adOHav6DgMtseybTtV9/JAEXAgO+FmLlX2sxpQIz6xL/MnP20E4j P28pSrHwoT/HmFuxOkdKGrrDk62OWnS6OfwQtATbN5xEbR2PwncJ6xz5WUYYK852Fr+0 fAPCjsMkQvwvks7REpWhDf5K7YOJ1gV5Skox9W5uoXnXmhi3C3+JoYotU0Yk04gvQAAr qYnJvcJuYkYZhnbRZVwiEO9a7MEW/Ddnj3qemRQODXfin2UbYNthz12jC4M5pLAbnMsf +zqAaQO6C1+w358Dwfvoc2bVAhOCHhprSUWso6/zcWiQuxSzGJcFd/tu9sHruUAWupEC curw== X-Gm-Message-State: AC+VfDyt0qHcUDb1JevCGavg4+M8UmJtTnncexSXBP99sgL3dlwwetqY VCFLAHSKG7SKArqW7gcwgw== X-Google-Smtp-Source: ACHHUZ7eBVoXvUzpnEf3GDChtDNenCaQKoZcCkXzXJ5F3K0hrKVdPhoCC8kS4fBa8omxMLrFjrMlNA== X-Received: by 2002:a9d:7858:0:b0:6ab:3367:795b with SMTP id c24-20020a9d7858000000b006ab3367795bmr257752otm.12.1686279873419; Thu, 08 Jun 2023 20:04:33 -0700 (PDT) Received: from localhost.localdomain ([116.128.244.169]) by smtp.gmail.com with ESMTPSA id a16-20020a62bd10000000b0065ecdefa57fsm1713778pff.0.2023.06.08.20.04.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 20:04:33 -0700 (PDT) From: sunliming To: mhiramat@kernel.org, beaub@linux.microsoft.com, rostedt@goodmis.org, shuah@kernel.org Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kelulanainsley@gmail.com, sunliming Subject: [PATCH v2 3/3] selftests/user_events: Add test cases when event is disabled Date: Fri, 9 Jun 2023 11:03:02 +0800 Message-Id: <20230609030302.1278716-4-sunliming@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230609030302.1278716-1-sunliming@kylinos.cn> References: <20230609030302.1278716-1-sunliming@kylinos.cn> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org When user_events are disabled, it's write operation should be fail. Add this test cases. Signed-off-by: sunliming --- tools/testing/selftests/user_events/ftrace_test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/testing/selftests/user_events/ftrace_test.c b/tools/testing/selftests/user_events/ftrace_test.c index d33bd31425db..cf52789bafda 100644 --- a/tools/testing/selftests/user_events/ftrace_test.c +++ b/tools/testing/selftests/user_events/ftrace_test.c @@ -297,6 +297,10 @@ TEST_F(user, write_events) { io[0].iov_base = ®.write_index; io[0].iov_len = sizeof(reg.write_index); + /* Write should fail when event is not enabled */ + ASSERT_EQ(-1, writev(self->data_fd, (const struct iovec *)io, 3)); + ASSERT_EQ(ENOENT, errno); + /* Enable event */ self->enable_fd = open(enable_file, O_RDWR); ASSERT_NE(-1, write(self->enable_fd, "1", sizeof("1")))