Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4308808ybi; Mon, 27 May 2019 15:43:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqwrQy/C/KJpc9KcVad0rPE3l/eRtpnzXrpGgrC4NahiuJHfjUKENnJu2hIDSert2vUtxNng X-Received: by 2002:aa7:90ca:: with SMTP id k10mr138661150pfk.20.1558996981242; Mon, 27 May 2019 15:43:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558996981; cv=none; d=google.com; s=arc-20160816; b=brKRK4llgaTsSXidAWfGSH5cQr5X9ZejUTQGoBT2Ku1Fe5Z5WHIBfgVeEI0SDoZY9/ 828ncf3kGKnGCw3tlw4vxkIgChG0Ov7xA5JLbxqaiFBTJuB1CnnFOxg9zkAnEzo7+o/s jwC803bwGt2V3iCLVarCANkRqNUFML/UcGoLZ0L+y9kwj+ArV4mDTLKAeokiNnPn83+0 XvtBLvDAC3sIJn5Ex1bREk03lLUGjezqGoyFk7nONa2rF2hBZjwkoibyCQWDm/2ZIZov P8m1bI7TQ0NjUy1KhYaXjGcTQ7CTzi2Lld8u686LISdY/fc5EjpZzw16EdolGDrSl4UJ TJjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CiRle/RF64/RiQtnrBwmK00paBOIMc3E1G1oZxR9Nuo=; b=oDdTU7YBAbxy2YsXOCiuCGRbFePtV1bafPqbvknE6fluCauZiV0uK7aD0yvr7cXgeY zbiUSG+LrtCMPrkeHsAlDNPYdH9OivAEFRK37eETtogGBQPB8xg/vrmVdESahGjgyD5K M03yxvLlbBuHqbu++YEEb9N3i8g/JwSqeVM2jVNRj7dd6iLKh0eNV+NW53/402hwgHi0 Ji+H2WsSfgsu3AqREtHyVt2QAPn7zIRbv+YnDiPOAo1+n2mpL8XGPuqoOBuwdtplxqTB i7D/sPZyukuhJCfAfQWguy+Jnqc/IXfy5GIgu72vsTy3DwQYcfWKOOf0s+k2p9ysnIYT 5L9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vXazr3El; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f3si20158966pld.434.2019.05.27.15.42.46; Mon, 27 May 2019 15:43:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vXazr3El; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727963AbfE0WkB (ORCPT + 99 others); Mon, 27 May 2019 18:40:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:45824 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727935AbfE0WkA (ORCPT ); Mon, 27 May 2019 18:40:00 -0400 Received: from quaco.ghostprotocols.net (179-240-171-7.3g.claro.net.br [179.240.171.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 426062133F; Mon, 27 May 2019 22:39:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558996799; bh=G2zIIWcfUV6fsFCNt+DEDTkIRgjAJs4zIcO7iTtCHTE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vXazr3ElQDD4RP4D+CJLRt35SlkcCFV8gohXbXcwg21qD9oCaucKE1zf5eBncmo7F CSz21GPUjlJ50xIpmdQmVmpphMbK+gCjgygxSZFoL8ECQ4tl6uMO5SHMMbACiR7U1c 2i1Id9v4ih3AI9xhGDZp2yH13ST0aQ5Hmgo7pGr0= From: Arnaldo Carvalho de Melo To: Ingo Molnar , Thomas Gleixner Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Arnaldo Carvalho de Melo , Hari Bathini , Jiri Olsa , Krister Johansen Subject: [PATCH 29/44] perf tools: Remove const from thread read accessors Date: Mon, 27 May 2019 19:37:15 -0300 Message-Id: <20190527223730.11474-30-acme@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190527223730.11474-1-acme@kernel.org> References: <20190527223730.11474-1-acme@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Namhyung Kim The namespaces and comm fields of a thread are protected by rwsem and require write access for it. So it ended up using a cast to remove the const qualifier. Let's get rid of the const then. Signed-off-by: Namhyung Kim Suggested-by: Arnaldo Carvalho de Melo Cc: Hari Bathini Cc: Jiri Olsa Cc: Krister Johansen Link: http://lkml.kernel.org/r/20190527061149.168640-1-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/hist.c | 2 +- tools/perf/util/thread.c | 12 ++++++------ tools/perf/util/thread.h | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 7ace7a10054d..fb3271fd420c 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -2561,7 +2561,7 @@ int __hists__scnprintf_title(struct hists *hists, char *bf, size_t size, bool sh char unit; int printed; const struct dso *dso = hists->dso_filter; - const struct thread *thread = hists->thread_filter; + struct thread *thread = hists->thread_filter; int socket_id = hists->socket_filter; unsigned long nr_samples = hists->stats.nr_events[PERF_RECORD_SAMPLE]; u64 nr_events = hists->stats.total_period; diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c index b413ba5b9835..aab7807d445f 100644 --- a/tools/perf/util/thread.c +++ b/tools/perf/util/thread.c @@ -141,13 +141,13 @@ static struct namespaces *__thread__namespaces(const struct thread *thread) return list_first_entry(&thread->namespaces_list, struct namespaces, list); } -struct namespaces *thread__namespaces(const struct thread *thread) +struct namespaces *thread__namespaces(struct thread *thread) { struct namespaces *ns; - down_read((struct rw_semaphore *)&thread->namespaces_lock); + down_read(&thread->namespaces_lock); ns = __thread__namespaces(thread); - up_read((struct rw_semaphore *)&thread->namespaces_lock); + up_read(&thread->namespaces_lock); return ns; } @@ -271,13 +271,13 @@ static const char *__thread__comm_str(const struct thread *thread) return comm__str(comm); } -const char *thread__comm_str(const struct thread *thread) +const char *thread__comm_str(struct thread *thread) { const char *str; - down_read((struct rw_semaphore *)&thread->comm_lock); + down_read(&thread->comm_lock); str = __thread__comm_str(thread); - up_read((struct rw_semaphore *)&thread->comm_lock); + up_read(&thread->comm_lock); return str; } diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h index cf8375c017a0..e97ef6977eb9 100644 --- a/tools/perf/util/thread.h +++ b/tools/perf/util/thread.h @@ -76,7 +76,7 @@ static inline void thread__exited(struct thread *thread) thread->dead = true; } -struct namespaces *thread__namespaces(const struct thread *thread); +struct namespaces *thread__namespaces(struct thread *thread); int thread__set_namespaces(struct thread *thread, u64 timestamp, struct namespaces_event *event); @@ -93,7 +93,7 @@ int thread__set_comm_from_proc(struct thread *thread); int thread__comm_len(struct thread *thread); struct comm *thread__comm(const struct thread *thread); struct comm *thread__exec_comm(const struct thread *thread); -const char *thread__comm_str(const struct thread *thread); +const char *thread__comm_str(struct thread *thread); int thread__insert_map(struct thread *thread, struct map *map); int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp, bool do_maps_clone); size_t thread__fprintf(struct thread *thread, FILE *fp); -- 2.20.1