Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1545383ybb; Thu, 9 Apr 2020 04:24:42 -0700 (PDT) X-Google-Smtp-Source: APiQypLTkwksuCNQT5F4tx506p4nUqqVwJvCPIzj6YgSYS6r6pdUJDDvVN3TKvCNnCFU+e+eIW30 X-Received: by 2002:a4a:a20b:: with SMTP id m11mr4315044ool.100.1586431482439; Thu, 09 Apr 2020 04:24:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586431482; cv=none; d=google.com; s=arc-20160816; b=fs8GSu6e5fdS/WQJUkpPcRB7zsbB8PjUmKHMF5IG6b3qVlPXYsCCYIbKFoTYgqCLTg GrywqTjjQbd72+tPL6AxrSw+kw6vi0Pn9tU/RqVBBIekH9F+5K7+gnETqp6wq5GM6Ywz UasM0/tnJs7Oaz1tQilK13WkNBxrv4u7KtMabYfPjtXdKmXllDBQ8sbOkhbnFRVtcrZt iPz71lxhs00XKgJZ1QoIcBLzxE1U1kstZc4BV0bZsuuMU6spUu0wiGJ+1cDq3MIV32DE YEU+PMyyJadBb+al564bsPTSth+qVo9BhRBIYRMdBElawnXbiLTO3Fc6He3zzDhCJ1bH HyPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=R/N1koIZFySw1ux/SpoK6+wk9KK1xvej+TtC1UP0rHQ=; b=l+a/9TKFcvB71WZro9UEF636os/nZOX90RHWQhGEZx/6/t8aM8KpBG9hf2tjDrwBrL xArIlWL4QWLPllNpb4FfSmENxWUMAvhjBgNrurl7wxu6NdSGqguxSgh9VPEXXPAoevwz pPxlKj5JrAkeOYTMmk3owCol57vsorN5pP1oz5/SVfzewfTC1lcJ4da4b6DkD7THJJ0Q qT+tA8xzOlgd+VIFBJ6d6hnrLqbA3slPYu0XXnlEiyY2gNXM5vEd7rUO9LG/ydirVNHg FgvOeS/2QVFgqfWP/4NOpMI/MnnleWEsN4TxNyUyYs62iDYd7F1bHqy67184R4wDqAhe MFxQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p2si3620947ota.143.2020.04.09.04.24.27; Thu, 09 Apr 2020 04:24:42 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726574AbgDILWa (ORCPT + 99 others); Thu, 9 Apr 2020 07:22:30 -0400 Received: from mx2.suse.de ([195.135.220.15]:33002 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725987AbgDILW3 (ORCPT ); Thu, 9 Apr 2020 07:22:29 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 9634EAE24; Thu, 9 Apr 2020 11:22:27 +0000 (UTC) Date: Thu, 9 Apr 2020 13:22:26 +0200 From: Michal =?iso-8859-1?Q?Such=E1nek?= To: Christophe Leroy Cc: linuxppc-dev@lists.ozlabs.org, Nicholas Piggin , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , linux-kernel@vger.kernel.org Subject: Re: [PATCH] powerpcs: perf: consolidate perf_callchain_user_64 and perf_callchain_user_32 Message-ID: <20200409112226.GT25468@kitsune.suse.cz> References: <1585896170.ohti800w9v.astroid@bobo.none> <20200406210022.32265-1-msuchanek@suse.de> <8786906b-edd5-e4a3-8286-33a05f39668c@c-s.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <8786906b-edd5-e4a3-8286-33a05f39668c@c-s.fr> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 07, 2020 at 07:21:06AM +0200, Christophe Leroy wrote: > > > Le 06/04/2020 ? 23:00, Michal Suchanek a ?crit?: > > perf_callchain_user_64 and perf_callchain_user_32 are nearly identical. > > Consolidate into one function with thin wrappers. > > > > Suggested-by: Nicholas Piggin > > Signed-off-by: Michal Suchanek > > --- > > arch/powerpc/perf/callchain.h | 24 +++++++++++++++++++++++- > > arch/powerpc/perf/callchain_32.c | 21 ++------------------- > > arch/powerpc/perf/callchain_64.c | 14 ++++---------- > > 3 files changed, 29 insertions(+), 30 deletions(-) > > > > diff --git a/arch/powerpc/perf/callchain.h b/arch/powerpc/perf/callchain.h > > index 7a2cb9e1181a..7540bb71cb60 100644 > > --- a/arch/powerpc/perf/callchain.h > > +++ b/arch/powerpc/perf/callchain.h > > @@ -2,7 +2,7 @@ > > #ifndef _POWERPC_PERF_CALLCHAIN_H > > #define _POWERPC_PERF_CALLCHAIN_H > > -int read_user_stack_slow(void __user *ptr, void *buf, int nb); > > +int read_user_stack_slow(const void __user *ptr, void *buf, int nb); > > Does the constification of ptr has to be in this patch ? It was in the original patch. The code is touched anyway. > Wouldn't it be better to have it as a separate patch ? Don't care much either way. Can resend it as separate patches. > > > void perf_callchain_user_64(struct perf_callchain_entry_ctx *entry, > > struct pt_regs *regs); > > void perf_callchain_user_32(struct perf_callchain_entry_ctx *entry, > > @@ -16,4 +16,26 @@ static inline bool invalid_user_sp(unsigned long sp) > > return (!sp || (sp & mask) || (sp > top)); > > } > > +/* > > + * On 32-bit we just access the address and let hash_page create a > > + * HPTE if necessary, so there is no need to fall back to reading > > + * the page tables. Since this is called at interrupt level, > > + * do_page_fault() won't treat a DSI as a page fault. > > + */ > > +static inline int __read_user_stack(const void __user *ptr, void *ret, > > + size_t size) > > +{ > > + int rc; > > + > > + if ((unsigned long)ptr > TASK_SIZE - size || > > + ((unsigned long)ptr & (size - 1))) > > + return -EFAULT; > > + rc = probe_user_read(ret, ptr, size); > > + > > + if (rc && IS_ENABLED(CONFIG_PPC64)) > > gcc is probably smart enough to deal with it efficiently, but it would > be more correct to test rc after checking CONFIG_PPC64. IS_ENABLED(CONFIG_PPC64) is constant so that part of the check should be compiled out in any case. Thanks Michal