Received: by 2002:a25:d783:0:0:0:0:0 with SMTP id o125csp689827ybg; Thu, 19 Mar 2020 07:05:53 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvjt82oPf2g4DQcA8ymrv3sbbfTZ7FbIAVg5gmb51g11E6hbfdBE59g6rN2vu+jAJn4teJq X-Received: by 2002:a9d:6ac6:: with SMTP id m6mr2548619otq.198.1584626753520; Thu, 19 Mar 2020 07:05:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584626753; cv=none; d=google.com; s=arc-20160816; b=Re8ueO7tHXd76USLE+eZNK5jsxOUeQmKu1caDqHJX7AjEQb7lphoIheCmricxQXS8Z 0o+qpDCFBG9sO6YhfFS5sYEs0nUng8lx9QZVF6CBJP045Vq9ihMLPxK1XdjsayMB8Iwe bQGIaYtmjHkdPmXeGMDa7lbOjJjUON6XYxWAWN/oT0LZQHIyQrV5XNnNy1sM6qyU2Q6I sQWREsOxvsqL/UDW8bFTwXhA/qV3QOWnZTkiKIlVxQ0gVmQRTv6MyorJq4GxstzDCfbe LrCs3ZX5Se3+rS25v5bQVLRXN7aN/j5GaZTyoniH0Dy66dHGB1vxa3V2cpthCnOWUKZD DAnA== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Opi99RHDQEYnw7Ih0O+PjXuklXtqLr3zE3h6nA2faOA=; b=bZC1Y/Dteb54Q2tO0wxmU+C9ETQE6tQCRKaGqAHnTPSlbnOhoCAj1+aKuEmqW1MiUQ Eb6MruDRwMyAFmMpqagWJrQieXIkA+GExDNLGuPpeG6G6OUxAWFBdIxC3OmWk1P1Xia2 R+sLa5nMAHnDWcHCZrWtV1ks0kd6/lkewwxeB2Mw3Fcr0NfS6R9djWob2bs/Am38wm+k wWnU5AHq6SsPvBxzj6WpxC9seVc3D611wS6tk9Wb3UZ2EGc64vZGnlmFNb9kh/OPyYwv soiLEjIuVpRG3t+MVWC/ytgZhhz6YcHfoU9O0gt6fI4LQHnWbHUUK26Fffke5zzyCBrG D7vA== 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 v126si1132953oia.106.2020.03.19.07.05.37; Thu, 19 Mar 2020 07:05:53 -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 S1727341AbgCSOEU (ORCPT + 99 others); Thu, 19 Mar 2020 10:04:20 -0400 Received: from mx2.suse.de ([195.135.220.15]:38060 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725787AbgCSOEU (ORCPT ); Thu, 19 Mar 2020 10:04:20 -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 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 Cc: "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 , Christophe Leroy , 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: <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) 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: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