From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5F9DC4332B for ; Thu, 19 Mar 2020 15:12:16 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A1A9E2072D for ; Thu, 19 Mar 2020 15:12:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A1A9E2072D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48jr3v1bD3zDrK4 for ; Fri, 20 Mar 2020 02:12:11 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=195.135.220.15; helo=mx2.suse.de; envelope-from=msuchanek@suse.de; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48jqVf63b3zDr6x for ; Fri, 20 Mar 2020 01:46:50 +1100 (AEDT) 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 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) X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Gustavo Luiz Duarte , Peter Zijlstra , Sebastian Andrzej Siewior , Linux Kernel Mailing List , Paul Mackerras , Jiri Olsa , Rob Herring , Michael Neuling , Mauro Carvalho Chehab , Masahiro Yamada , Nayna Jain , "linux-fsdevel @ vger . kernel . org --in-reply-to=" <20200225173541.1549955-1-npiggin@gmail.com>, Alexander Shishkin , Andy Shevchenko , Ingo Molnar , Allison Randal , Jordan Niethe , Valentin Schneider , Arnd Bergmann , Arnaldo Carvalho de Melo , Alexander Viro , Jonathan Cameron , Namhyung Kim , Thomas Gleixner , Andy Shevchenko , Hari Bathini , Greg Kroah-Hartman , Nicholas Piggin , Claudio Carvalho , Eric Richter , "Eric W. Biederman" , "open list:LINUX FOR POWERPC PA SEMI PWRFICIENT" , "David S. Miller" , Thiago Jung Bauermann Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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