Received: by 2002:a17:90a:1609:0:0:0:0 with SMTP id n9csp579675pja; Thu, 19 Mar 2020 07:49:00 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsVl5DI7gA1OrPnQzzhT5jS3XAs+NCScGJjtkI6Cjr2BbnvI1FbY0kq9BoTXUJCNZVv/DGQ X-Received: by 2002:a05:6830:210d:: with SMTP id i13mr2740399otc.104.1584629340511; Thu, 19 Mar 2020 07:49:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584629340; cv=none; d=google.com; s=arc-20160816; b=gb3lhtsRvnpOTyuM21eXAX9A3UbFRJZ2jU37vtjJ0i8JeVYQmwX6T7G4ud6PCoKXWF AXB7ja29iNgZ0Ah7etur3jzFvi1MODlDVesHPLhJ2+AtpiQa95eHVGSvdZ60I/kKVzFG ho+pKt1BtzxM+j+kEo55lw2I3tO9LHLezHTVdLm1NCKTLTPo3VfUzdhhF/q+1EWM30CG SZKcgvETH5Mfmh+qcUFtqlFJlrV9iN3G+H5QzFvko2i8fCsgiZy6n7iUeNl8Qpasw2ji BFGzO7lrtbH0dQtSWWQL3FdESKc1iZ7xo1rgCQ7kzi47M73AolRpqcARTcVjBy+sntOs WpEQ== 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=Poj0ppMc8oOKM0h44jWxOMuOGhtHX2/+xbNkQ2wKJWc=; b=vKIJRA6BSzDv12sQ/MZuHMJ9l6L1jwfCn/faBb/2W3X2mMOxWBIQf4a/S1ZDNzJx/k OYYZtEXOa0FN1V6MjC6rTDK/ScrbA8FLyL1PDsVA7ZAWnqEUwF1MALDpVUK5u3G/OV5N aakGrqdwAc6pGGmMCeo03eqHInU3kHjuRSPDL0PwaA8gAzGvpKLRUwj6J2YuEZok23Ee AqujjwVNZaW8+W1sZIk2JJXkYuHHGT7xdh7lcEei1bgHFMbNm4nfU5GMow+aF+zsUaE3 3O0SlKRXxrPCZQzbNGd5AfgzV11HONU3S/yOU734B2erIfl0zlkw4FrcVlQOGgC2rMPL 7FkA== 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 a13si1603411otk.158.2020.03.19.07.48.42; Thu, 19 Mar 2020 07:49:00 -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 S1727357AbgCSOqt (ORCPT + 99 others); Thu, 19 Mar 2020 10:46:49 -0400 Received: from mx2.suse.de ([195.135.220.15]:42876 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727095AbgCSOqs (ORCPT ); Thu, 19 Mar 2020 10:46:48 -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 0A894AC66; Thu, 19 Mar 2020 14:46:44 +0000 (UTC) Date: Thu, 19 Mar 2020 15:46:42 +0100 From: Michal =?iso-8859-1?Q?Such=E1nek?= To: Christophe Leroy Cc: Andy Shevchenko , "open list:LINUX FOR POWERPC PA SEMI PWRFICIENT" , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Alexander Viro , Mauro Carvalho Chehab , "David S. Miller" , Rob Herring , Greg Kroah-Hartman , Jonathan Cameron , Andy Shevchenko , Thomas Gleixner , Arnd Bergmann , Nayna Jain , Eric Richter , Claudio Carvalho , Nicholas Piggin , Hari Bathini , Masahiro Yamada , Thiago Jung Bauermann , Sebastian Andrzej Siewior , Valentin Schneider , Jordan Niethe , Michael Neuling , Gustavo Luiz Duarte , Allison Randal , "Eric W. Biederman" , Linux Kernel Mailing List , "linux-fsdevel @ vger . kernel . org --in-reply-to=" <20200225173541.1549955-1-npiggin@gmail.com> Subject: Re: [PATCH v11 4/8] powerpc/perf: consolidate valid_user_sp Message-ID: <20200319144642.GL25468@kitsune.suse.cz> References: <1b612025371bb9f2bcce72c700c809ae29e57392.1584613649.git.msuchanek@suse.de> <8775f299-be1b-3457-c59d-e4f61d8223e5@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: <8775f299-be1b-3457-c59d-e4f61d8223e5@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 Thu, Mar 19, 2020 at 03:16:03PM +0100, Christophe Leroy wrote: > > > Le 19/03/2020 ? 14:35, Andy Shevchenko a ?crit?: > > On Thu, Mar 19, 2020 at 1:54 PM Michal Suchanek wrote: > > > > > > Merge the 32bit and 64bit version. > > > > > > Halve the check constants on 32bit. > > > > > > Use STACK_TOP since it is defined. > > > > > > Passing is_64 is now redundant since is_32bit_task() is used to > > > determine which callchain variant should be used. Use STACK_TOP and > > > is_32bit_task() directly. > > > > > > This removes a page from the valid 32bit area on 64bit: > > > #define TASK_SIZE_USER32 (0x0000000100000000UL - (1 * PAGE_SIZE)) > > > #define STACK_TOP_USER32 TASK_SIZE_USER32 > > > > ... > > > > > +static inline int valid_user_sp(unsigned long sp) > > > +{ > > > + bool is_64 = !is_32bit_task(); > > > + > > > + if (!sp || (sp & (is_64 ? 7 : 3)) || sp > STACK_TOP - (is_64 ? 32 : 16)) > > > + return 0; > > > + return 1; > > > +} > > > > Other possibility: > > I prefer this one. > > > > > unsigned long align = is_32bit_task() ? 3 : 7; > > I would call it mask instead of align > > > unsigned long top = STACK_TOP - (is_32bit_task() ? 16 : 32); > > > > return !(!sp || (sp & align) || sp > top); And we can avoid the inversion here as well as in !valid_user_sp(sp) by changing to invalid_user_sp. Thanks Michal