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 5C32CC4332D for ; Thu, 19 Mar 2020 14:40:40 +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 1B3FB20782 for ; Thu, 19 Mar 2020 14:40:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1B3FB20782 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 48jqMV05QkzDr3S for ; Fri, 20 Mar 2020 01:40:38 +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 48jpYh17PjzDqnD for ; Fri, 20 Mar 2020 01:04:24 +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 959CDAE63; Thu, 19 Mar 2020 14:04:18 +0000 (UTC) Date: Thu, 19 Mar 2020 15:04:16 +0100 From: Michal =?iso-8859-1?Q?Such=E1nek?= To: Andy Shevchenko Subject: Re: [PATCH v11 4/8] powerpc/perf: consolidate valid_user_sp Message-ID: <20200319140416.GK25468@kitsune.suse.cz> References: <1b612025371bb9f2bcce72c700c809ae29e57392.1584613649.git.msuchanek@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 , 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:35:03PM +0200, Andy Shevchenko wrote: > 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; > > +} > > Perhaps better to read > > if (!sp) > return 0; > > if (is_32bit_task()) { > if (sp & 0x03) > return 0; > if (sp > STACK_TOP - 16) > return 0; > } else { > ... > } > > return 1; > > Other possibility: > > unsigned long align = is_32bit_task() ? 3 : 7; > unsigned long top = STACK_TOP - (is_32bit_task() ? 16 : 32); > > return !(!sp || (sp & align) || sp > top); Sounds reasonale. Thanks Michal > > -- > With Best Regards, > Andy Shevchenko