From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78A432DC344 for ; Wed, 3 Jun 2026 16:13:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780503183; cv=none; b=gx1EZZxc0l9vvdLxLvM0tXsbGM1QGeZ9AYR6phZVRtlERjIQ+IpzbIyYVnSqIXpVOOj5rHyKvOEr6yqKk0/3KQrwKSw35ecM27ApTgrnpewyX2yWa4CZOoc8n7DoFeH+7d65Qhn0UOwsLx44pwc5rNqGJ2WEn9uAbznnK83V9iw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780503183; c=relaxed/simple; bh=+GWdI5GaapuuPFkF+1pWn80E7RwfKlyV8xsbbbZwENQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=jqWq9Ii5GTKlRt04A5bsMkIFkK3wbmxA9p/EdJeMMj9znKt3vBBH8lB2SvFsmOG2dWyi39kxiC7f406cCzPIQ2Eff4cDhIgDL4w3lpzqMTqoVAUHAbkohfihLlNm2VeasGTd420pP2i5+eVlYocI50wpqXr0YJGNvqw+yNkvOhw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=riatndP2; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="riatndP2" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-490abf12f0fso5323245e9.0 for ; Wed, 03 Jun 2026 09:13:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1780503181; x=1781107981; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=UKULipB408ValDz8ua2CahzCEdZz52u0U+4kqUbz4QE=; b=riatndP2zNdhheLMEwL7VGYbzX2Iy7YfvM/aw7VA5Bofg20hjX1FxB5C0BfjvAtQb+ VghOksLuXAq6U5KKp6YTDoTGrV3rY9QdtU/fyefANqSNBbuGk2Sz3Y6mNOpfyTY3B3rW 7VNppayma/4m8Q5dLSH8KvFAbRZgs+a9P+DyIm4LTiyOuGUShFyVcCBgaUZ6Aewy6RZu aSAI8z3iVVp0YERQvmUtf7N6EJu6mPe5apBzB9RplthQJEtIUyay+uirxjr3p2PC72zF e/vO+dWtZXa9DAk8d9wcHTcKK6O3vMZYDLy05oaVG6L7KmA388uvEPQcRNVuP1leW8+o 8N7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780503181; x=1781107981; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=UKULipB408ValDz8ua2CahzCEdZz52u0U+4kqUbz4QE=; b=bwqD1eJj27JkSm5WSELS1N1wcP+C18761r5yO/KJ0yb306t4HhSQgeMeUPg52t49fC A8xV41fV3+K/qktDM9Vve9DH/JkLNeo+aAv7lOlInciVbTsqT8gb9+1Y+IAZahALZKEt 681QDSgRUxGNsBp3bJbHXG9XI0trO4SWS0SgVRcyjtIDICU41aYuEWYbSGP+GeC68z9d x1O5Sn1R5jBMntDJ0vWpNCAFhILrKbKjNpNsCVitjrjMLUIqpWUD2xWiO2pghsmJ8UBI fg7Se1iOPldzoy9cxGiCo2Nq0bFoQA9UwCWjp1ddQ5Gso7+rToIuEXmWW8R+1c+VnWSu VbPA== X-Forwarded-Encrypted: i=1; AFNElJ+ueg0FFmi0bSwCbsfjkelm7bB51WDCg47E/njiZEZh3DOb31mQQqdPnLxln9VX/vmw344ycScPhPqwYzc=@vger.kernel.org X-Gm-Message-State: AOJu0YxNrT9mmVZ0dtXxik74zFqv3yQKQK72dVaBwtaBma+QuCNx3rzA neeNFMjR4ddZOLasShWQfHvjX3nfpZuKpZwkwOE4yfN870Yre0q7rvWViV7mYc8AKp4= X-Gm-Gg: Acq92OHGQi9M/Ucg7h6uxaH/AB0DBX2DXaC8jHnpQFCuvBHzmwu4ZAreyCBeIB3jB3A qO3N0GaBa2kwA1QtwmN1Q/mf37D+oFfDs/YGEGNehUm893IfQ5fESTF2bzTwZtbMgHX7HHOwUtK JtPrS2yh+ZbzF6J6NglkOzP3xhc/oEl9BhDUGnxhvlXHVKhj1pZ2kVRlTEhpD3KAKNUTPpkCXP7 ZU0oBU1AZ8r7JgoCImjc7Oln9+fzgnBf3JmYir7/jb7rduy5mJT429DEjqyxSpEZPzkjehXlPtZ 5ATn9U1X7VjdDfoCMNnU2nYXeOA4uP1qFNQ/tIysVFJMoXGpazBxjMGWc7GG+X+aZqkqsnRDZRx uRqO/uliJdM9qOqjI9AS0+LlhucRf4JQLAvO6I5z71Q2tXE19QFcl6pfYriFJgJfKKOjQDQY3OA iZO91hEWYl2XLuXVRIoKU+Lk6cGSxq4aZCSHZva3s= X-Received: by 2002:a05:600c:810b:b0:490:8b0b:d3b1 with SMTP id 5b1f17b1804b1-490bc4f9846mr622895e9.12.1780503180885; Wed, 03 Jun 2026 09:13:00 -0700 (PDT) Received: from [192.168.1.3] ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490b7a7cb85sm70950515e9.1.2026.06.03.09.12.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 03 Jun 2026 09:13:00 -0700 (PDT) Message-ID: <5e29907a-2533-4540-833f-977c5f0fb90b@linaro.org> Date: Wed, 3 Jun 2026 17:12:59 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 09/18] perf test: Add named_threads workload To: Leo Yan Cc: Suzuki K Poulose , Mike Leach , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Amir Ayupov , Jonathan Corbet , Shuah Khan , Paschalis Mpeis , coresight@lists.linaro.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , linux-doc@vger.kernel.org References: <20260602-james-cs-context-tracking-fix-v2-0-85b5ce6f55c6@linaro.org> <20260602-james-cs-context-tracking-fix-v2-9-85b5ce6f55c6@linaro.org> <20260603145415.GY101133@e132581.arm.com> Content-Language: en-US From: James Clark In-Reply-To: <20260603145415.GY101133@e132581.arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 03/06/2026 3:54 pm, Leo Yan wrote: > On Tue, Jun 02, 2026 at 03:26:51PM +0100, James Clark wrote: > >> +#define DEFINE_THREAD(n) \ >> +noinline void *named_threads_thread##n(void *arg __maybe_unused) \ >> +{ \ >> + pthread_setname_np(pthread_self(), "thread" #n); \ >> + for (int i = 0; i < iterations; i++) \ >> + named_threads_work *= 3; \ >> + \ >> + return NULL; \ >> +} > >> +static int named_threads(int argc, const char **argv) >> +{ >> + pthread_t threads[MAX_THREADS]; >> + int nr_threads = 1; >> + int err = 0; >> + >> + if (argc > 0) >> + nr_threads = atoi(argv[0]); >> + >> + if (nr_threads <= 0 || nr_threads > MAX_THREADS) { >> + fprintf(stderr, "Error: num threads must be 1 - %d\n", MAX_THREADS); >> + return 1; >> + } >> + >> + if (argc > 1) >> + iterations = atoi(argv[1]); >> + >> + if (iterations < 0) { >> + fprintf(stderr, "Error: iterations must be non-negative\n"); >> + return 1; >> + } >> + >> + for (int i = 0; i < nr_threads; i++) { >> + int ret; >> + >> + ret = pthread_create(&threads[i], NULL, thread_fns[i], NULL); > > Just curious this can be simplified to a thread function, like: > > noinline void *named_thread(void *arg) > { > char name[16]; > > snprintf(name, sizeof(name), "thread%d", int(arg)); > > pthread_setname_np(pthread_self(), name); > ... > return NULL; > } > > Thanks, > Leo Only if you don't want to check for symbols as well. I thought if we were going to spawn a load of threads and look for thread names we might as well check that the symbols match at the same time. If all of the threads run the same function you can't do that.