Received: by 2002:a25:d783:0:0:0:0:0 with SMTP id o125csp661762ybg; Thu, 19 Mar 2020 06:35:45 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt3j0Kh806m7PtLCVgTjuky3I0SIPAyg/YcgvFbAxfDTbIQMUmKdK7i6XmtzI4dOryW3YKs X-Received: by 2002:a9d:3ea4:: with SMTP id b33mr2277315otc.136.1584624945311; Thu, 19 Mar 2020 06:35:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584624945; cv=none; d=google.com; s=arc-20160816; b=OVzXF/Smh/nxEv2uKZeOX3aiXPfXaMmFuu3tBIBk5vT2XtxPHWk2+Mh7i8CL0loPAS 8JGc4VWV/7kM5HMwPdUhOz4LLYOAop6ia9BRBo7zOCTpuXtFAoWJOshdjm3neDJJuIdb GEsS+Y6L4KkAazwbSClAwKaH0uo6RrPbB6taXGOakzmbbddXu7jSy9m4DChPDtRokXIk wavREtH/qc1MBTkKYy1sXydpj6uJoZipjZD/4Z7Rbca4y9Pnh4xrNXnDzYEvvZ+im2HB Ky6W98I5RsSiLe5be3pYoqhoLfDXQrsYRXEcmieYrosnXs0VbnSnogKe5RC/l+Fgdeb7 c3Xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=ket5nG48OjRkSmjRLhm6o/GZWaiXnw2ieKQdmnyTlMc=; b=qjnAgB4D/ZIEaOmseCZ48P7PKGmq/1/BgqFfJBK6lKckaieGyPghok+7WIX283rhg/ SS7dvzDFd0g0nvNr+tZ/etwMjWmfyp+sphdtC+wNDgIBTjhAHHvUeAatTS6fk70IFlYZ kEKhC67XHwNTe0LPHaVZ4h2XzvG+zXXM/w3yhxjtAi0LDCzAtfVkjHBtID8LAlwofzcg VxgJhTJLbBJ8wT2L1wYiFCTdGEVUYOd2RGpIvigBckVhleNeQS5Rajebmz5NbxPcHIAp St+3/+OQpVLkwWwmHYnl1VElejasVqnWqEECB+IhbJUH5JC1Qqb2wU4LbFQlMc2UWAxU aZLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Bh5NyyG1; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f20si1176905oti.224.2020.03.19.06.35.33; Thu, 19 Mar 2020 06:35:45 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Bh5NyyG1; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727755AbgCSNfO (ORCPT + 99 others); Thu, 19 Mar 2020 09:35:14 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:39199 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727320AbgCSNfN (ORCPT ); Thu, 19 Mar 2020 09:35:13 -0400 Received: by mail-pf1-f195.google.com with SMTP id d25so1441581pfn.6 for ; Thu, 19 Mar 2020 06:35:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ket5nG48OjRkSmjRLhm6o/GZWaiXnw2ieKQdmnyTlMc=; b=Bh5NyyG1M8gtKQIPrZf/5qLuu0ztHrg/ar6jVL2/WT1taChSOWg/KvzKJbbR0KSYtR XPtaZguXMqGkXBJ3gJyLO7wN+gVjLuV9q3Tz8TwQGSGAjkytzkvd45orPduurhypW4gD yJO04p/sjDB3DsSwi3caCRbP2G4wKsjv3RFhMMrqRyLk1I17Hd7iKJTiXBdaQKPXCmbG /NP1TWBrM/8HPRvMvfpqj8Jq2nmMrWRYtiIF3ldTvwMzZPlyYJxZwNVJiKpxUepjxUOW 3Rs27tmyLu3uAw+5+1836CWrZplMOz3sKM7WD7zh+xZEVScIfOCeygBpVOiyZhii8JwD BWgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ket5nG48OjRkSmjRLhm6o/GZWaiXnw2ieKQdmnyTlMc=; b=CKTeargNKD5IwJ5jnXtWN8AbXNXw/aefnb0QnfvofwZFj1CoVrC+5IaSTbuG5Cgx6W a7YDTbLe1XamtiXG6540TVMldKMIZaMVfG2Vi3ed8THGrjCH7AiEqHBeNaUAGu+W9Zrw gS7aqScBUIhg2M1ppySat07kM3z/zZ6/2CSyHKQwDyij6Z6qSx6cc5CgDTWkWUW/LU6J xO+Hu0yG9iwGPqQrucwHFIO5v7TxJnlYIQFZwf+19IdGdjSws7mfIueH8CXYOUm+UOgW uEPEpr7yy6lWXQCXWA0XOGUm/0XUtlhPU+8NI6NArNSpfZ02AIyCa69umQyQlNwbwoHU BrKA== X-Gm-Message-State: ANhLgQ0h5sL1PyeQVOzw6ATyOTbC/jxbxBpXJ4CAWXyquk783h0ToE3y q+K889i0WCCzbimjsIaSj8EaVOExT9grixMzBYM= X-Received: by 2002:a63:1c4d:: with SMTP id c13mr3369187pgm.4.1584624911491; Thu, 19 Mar 2020 06:35:11 -0700 (PDT) MIME-Version: 1.0 References: <1b612025371bb9f2bcce72c700c809ae29e57392.1584613649.git.msuchanek@suse.de> In-Reply-To: <1b612025371bb9f2bcce72c700c809ae29e57392.1584613649.git.msuchanek@suse.de> From: Andy Shevchenko Date: Thu, 19 Mar 2020 15:35:03 +0200 Message-ID: Subject: Re: [PATCH v11 4/8] powerpc/perf: consolidate valid_user_sp To: Michal Suchanek 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> Content-Type: text/plain; charset="UTF-8" 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 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); -- With Best Regards, Andy Shevchenko