Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp239185ybg; Thu, 17 Oct 2019 22:10:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqwi6zKCLU/XYqVvFpishJb4DVBmhmfovPgZqggJ4Sw82c4tkEznW/OYkvI6Iz+IIYOAzRgf X-Received: by 2002:a50:ce06:: with SMTP id y6mr7685599edi.259.1571375459280; Thu, 17 Oct 2019 22:10:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571375459; cv=none; d=google.com; s=arc-20160816; b=o/uCQjfaZtnXZ2SbZweML/NKoyRAcqgPq9QbNtp//nCRjaem3FyKM8qtWM6htZUnkY Q9hyqzbCsckVAbu6Fy10TBBQwsvLmO/toM2hehv+0aygogbPuaq4pPTN0Ft31Jj1ol5d cHipaY5DjpFrdA6DPY/ZMjuN7WYff5hOmNZNhB66Hk2SifluRQfSTNRnn6CtwUt0TtOo 3qljSUbcYQB9bfodJf1iFMfeqcjqRZfyi8g+Hs5Wz4k3SpXtV8rvWFNeELJSbY/Ha1c8 D64IwL/Ng87W9eTn0BuIxizga89Ip+ntVm0qe+2SnrIUK3xIaArvCYr/k6gWEmO2Ma8B 6iCQ== 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=dvr2k2cesqfqWN6XGDafc/ENwBi4+yjAQQmmpnGGw1M=; b=d/Wv/PSbnUk+x0BjbTvl3YAJvrxKrMoPLFH0tpG/wlLIbJDeICM1RiyThoDxC39YJf CkFOVq/+GxFPz6pJXU//+kzpMoqhN8Gacw2QTcZKRslnllN+VGhfu97pj2P8YautRMay m2zXRoGbP17biZ+823OYdCbvYKofBNu8LDlsL+jlgapdpZTRpdhNT+SvuxiL0oENMu5G z5CRNHVeG8K75fxYRDKLgOO+SMapaOIl130RJvJMdhVCDfvAvzgK+3SQjLzBMRepb2mC Zivnq6wwCzZkW4NnQ7Ih//Sn2DM1f5EpsDPolnDVp6XzHOs+9vfSuEOjJDb8VqJIdC57 KHbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=j5ZVArQN; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f13si3113289ejj.402.2019.10.17.22.10.36; Thu, 17 Oct 2019 22:10:59 -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=@google.com header.s=20161025 header.b=j5ZVArQN; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391108AbfJPXFl (ORCPT + 99 others); Wed, 16 Oct 2019 19:05:41 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:46517 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731616AbfJPXFk (ORCPT ); Wed, 16 Oct 2019 19:05:40 -0400 Received: by mail-pf1-f193.google.com with SMTP id q5so309701pfg.13 for ; Wed, 16 Oct 2019 16:05:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dvr2k2cesqfqWN6XGDafc/ENwBi4+yjAQQmmpnGGw1M=; b=j5ZVArQNVMKzmkp+DRled9bM3rrZ/59tqf72vSdYRblhYDT7OdWKSLu8b4ZhXvnmWY RBe0YRjhf+228rDoYlf1FOs4ipUl2vCn9ce/y0H5bt1n78fFi7EPW7r9mFDM9Ik5sCXP KFOR6Nb0NkY46WU7xEUn9swCntPjQuLCqe77V1vMCY9uB7LPhRf7+KIZMiZy4wC43aKK nmHGIn9otzLVJrfckmeEO6poTKol439elLaDIeGXgzoFcueonkBUVSY1XF1q1BpFvPDG u1REr8fQmr++x737PzzimqhhHDd17CdN2S7h/RHfj/hDR5iMB+msu5M68JbMPAfEV35u OukA== 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=dvr2k2cesqfqWN6XGDafc/ENwBi4+yjAQQmmpnGGw1M=; b=guejIYVhshw5tmOkRwgTyAQ+HcqNqiKOtxl5b0ySY97G9Z7O+6NvWMVyqoyFVbFPYz ZM8cJvefqJ0mWZWtnUHto/5cMEgIAtDbzKCQ65H4TutL+RzW31KMIJMNmBmnYZcBobHw 00h6Opo285eGXu2zTLGVJMd+MI7AL2vHRtyUipQiPW7WwQmX3vvhh8/DX7M16cu10IJx 2b2kQG2aDSjNdWgaxrTBw8I3YbnfWzIl4/HjRH0op0PAEo/9DGbyLvpJTf74HFVb49wm d2sTJD14WJUgm44h7IgpkYxRFdJpnlIIvK62Ut8mIqJnDVsjMGAH8BRBCHOmjM9Ay1NV g8Dw== X-Gm-Message-State: APjAAAX91dg6FQq1SJsfawG4yVG9uztbyOSmViOXFsKb/L9MgPR5fYzD jnR3dkp6qIgyPu+ByWoUNP+25Hp4W67xG+squNDqNA== X-Received: by 2002:a63:5448:: with SMTP id e8mr679797pgm.10.1571267138767; Wed, 16 Oct 2019 16:05:38 -0700 (PDT) MIME-Version: 1.0 References: <9e4d6378-5032-8521-13a9-d9d9519d07de@amd.com> <20191015202636.GA1671072@rani> <20191016185500.GA2674383@rani> In-Reply-To: <20191016185500.GA2674383@rani> From: Nick Desaulniers Date: Wed, 16 Oct 2019 16:05:27 -0700 Message-ID: Subject: Re: AMDGPU and 16B stack alignment To: Arvind Sankar Cc: Arnd Bergmann , "S, Shirish" , "Wentland, Harry" , "Deucher, Alexander" , "yshuiv7@gmail.com" , "andrew.cooper3@citrix.com" , clang-built-linux , Matthias Kaehlcke , "S, Shirish" , "Zhou, David(ChunMing)" , "Koenig, Christian" , amd-gfx list , LKML 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 Wed, Oct 16, 2019 at 11:55 AM Arvind Sankar wrote: > > On Tue, Oct 15, 2019 at 06:51:26PM -0700, Nick Desaulniers wrote: > > On Tue, Oct 15, 2019 at 1:26 PM Arvind Sankar wrote: > > > > > > On Tue, Oct 15, 2019 at 11:05:56AM -0700, Nick Desaulniers wrote: > > > > Hmmm...I would have liked to remove it outright, as it is an ABI > > > > mismatch that is likely to result in instability and non-fun-to-debug > > > > runtime issues in the future. I suspect my patch does work for GCC > > > > 7.1+. The question is: Do we want to either: > > > > 1. mark AMDGPU broken for GCC < 7.1, or > > > > 2. continue supporting it via stack alignment mismatch? > > > > > > > > 2 is brittle, and may break at any point in the future, but if it's > > > > working for someone it does make me feel bad to outright disable it. > > > > What I'd image 2 looks like is (psuedo code in a Makefile): > > > > > > > > if CC_IS_GCC && GCC_VERSION < 7.1: > > > > set stack alignment to 16B and hope for the best > > > > > > > > So my diff would be amended to keep the stack alignment flags, but > > > > only to support GCC < 7.1. And that assumes my change compiles with > > > > GCC 7.1+. (Looks like it does for me locally with GCC 8.3, but I would > > > > feel even more confident if someone with hardware to test on and GCC > > > > 7.1+ could boot test). > > > > -- > > > > Thanks, > > > > ~Nick Desaulniers > > > > > > If we do keep it, would adding -mstackrealign make it more robust? > > > That's simple and will only add the alignment to functions that require > > > 16-byte alignment (at least on gcc). > > > > I think there's also `-mincoming-stack-boundary=`. > > https://github.com/ClangBuiltLinux/linux/issues/735#issuecomment-540038017 > > Yes, but -mstackrealign looks like it's supported by clang as well. Good to know, but I want less duct tape, not more. > > > > > > > > Alternative is to use > > > __attribute__((force_align_arg_pointer)) on functions that might be > > > called from 8-byte-aligned code. > > > > Which is hard to automate and easy to forget. Likely a large diff to fix today. > > Right, this is a no-go, esp to just fix old compilers. > > > > > > > > It looks like -mstackrealign should work from gcc 5.3 onwards. > > > > The kernel would generally like to support GCC 4.9+. > > > > There's plenty of different ways to keep layering on duct tape and > > bailing wire to support differing ABIs, but that's just adding > > technical debt that will have to be repaid one day. That's why the > > cleanest solution IMO is mark the driver broken for old toolchains, > > and use a code-base-consistent stack alignment. Bending over > > backwards to support old toolchains means accepting stack alignment > > mismatches, which is in the "unspecified behavior" ring of the > > "undefined behavior" Venn diagram. I have the same opinion on relying > > on explicitly undefined behavior. > > > > I'll send patches for fixing up Clang, but please consider my strong > > advice to generally avoid stack alignment mismatches, regardless of > > compiler. > > -- > > Thanks, > > ~Nick Desaulniers > > What I suggested was in reference to your proposal for dropping the > -mpreferred-stack-boundary=4 for modern compilers, but keeping it for > <7.1. -mstackrealign would at least let 5.3 onwards be less likely to > break (and it doesn't error before then, I think it just doesn't > actually do anything, so no worse than now at least). > > Simply dropping support for <7.1 would be cleanest, yes, but it sounds > like people don't want to go that far. That's fair. I've included your suggestions in the commit message of 02/03 of a series I just sent but forgot to in reply to this thread: https://lkml.org/lkml/2019/10/16/1700 Also, I do appreciate the suggestions and understand the value of brainstorming. -- Thanks, ~Nick Desaulniers