Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3116603yba; Mon, 22 Apr 2019 20:26:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqxVaN07H1McPkZh1Ns4vxtZ6mGzn5ZCqBs0J0t2oO+tRvMgJfzvvDhMip40zKZyX581xavT X-Received: by 2002:a65:6392:: with SMTP id h18mr22100491pgv.273.1555989965522; Mon, 22 Apr 2019 20:26:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555989965; cv=none; d=google.com; s=arc-20160816; b=nb2GF3SU50n7Rt+92dV9mwSbwAii8grIw065NBrkbxjA7eJshPlCQ2LnrxVYvyOhvs v4a/LAz+SKyWvLAp9RogrqmnONCTpZXQd0sZIsZx827HKiWh2N6ZTA7XyEy+vKmbUTVA VveL1fdxftLYHwCHbCkEBCMJ69zCE8H5j9BOdAo9e2E3AMPaQvEF72OBRqj+n/rY7i5H eCNnmETe4NtdawUKH2GW6Vd4TAQ6IrvuRi3QS2H9JP0IINEWqMT5EzJc23VKl6IklPly 8Nimv0cetN4/DJUgRxBEBlD0SOjLbeR2My55DT37Ad+q4ZVgjh00bNmVYvZ1Or8cBuGI iCVQ== 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=u4+uIj7flcxGFYwj/tSELT+9Omb2XPMc6XJsVtpD7rM=; b=c1Lu+i2Hbux7jdr2JxCyY5ozn3DloYYFUWwLznroJBKsvnzw8qzgRB1Vsn3KLK0bwJ lI9UDUR2VZN8PII6ZVP7p5tF2PtvXtUbBThlXmrglz2pwZdzVfkCy84vRnDOt18lHgzI 3PygJD+2PrjoVgiIURiVFdNS1Zk0xwA7mrUHNqVNfg0vy+YAd2nUBXqM0KHdpIwukSxd Czb6WgGg7cUEJL5V1jPxzG0Vqo5m/Pg0iJs6DmSdFu8dBxPU/Pru3mBLvIGA1oaYhZNj YIhVsKQqqaPX6vPiNw+Al3UKLTjhTvZRUZMuZ2xiBhbGlm6lSaezRPSjtRgkEf7bwbvg t9bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=RxxH0fkU; 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 d4si15004921plr.301.2019.04.22.20.25.50; Mon, 22 Apr 2019 20:26:05 -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=@linux-foundation.org header.s=google header.b=RxxH0fkU; 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 S1729629AbfDVWkV (ORCPT + 99 others); Mon, 22 Apr 2019 18:40:21 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:33795 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728965AbfDVWkV (ORCPT ); Mon, 22 Apr 2019 18:40:21 -0400 Received: by mail-lj1-f193.google.com with SMTP id y16so840442ljg.1 for ; Mon, 22 Apr 2019 15:40:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=u4+uIj7flcxGFYwj/tSELT+9Omb2XPMc6XJsVtpD7rM=; b=RxxH0fkU/TvgkBeVGHr1NeVrwv1sCkt3Lv8R0pHGRYrVi3TSay2ZUu5f8wEptb5i1/ VsBgIRAi0mIzTvUEMoZ/6sCE+vA11AN1tuItLytFfErPkcy7z+CMRAwkqhMFYisWPW19 SEGKgfH6yqS/Ea0zjmHGg1l6o51jENsOkRl/Q= 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=u4+uIj7flcxGFYwj/tSELT+9Omb2XPMc6XJsVtpD7rM=; b=V1V7VdyuPFOhQoZIkwREYVCx6CinFc2Gt24RhkWqxmbRJkoRtE50017llAxSe4UQZX FKNAAQAjcgJw6AzFZBqcpvDIVEzS1HRRk8uIsn7QB0umCo0WnxuRhe4JHNATeqXujMRB sLSBIiW1LXw77t0PR2My7tYxq29xZqA8W5KputqxcO4dKUJeP0NA0ZxMWB9Di+QuIVSd oWnR49uvUdbLyS26dzDizp5N1YFC6DWMUafBTpzlcAmKYvU96chkNXS9kzyIap+F7U0U vRNQdHgVFLrJvV2rpQrMC4lldTye9a4sr3VJpUmXhxpK6uefDL+kOOIDN+Qo9kFrBw0P 8kvQ== X-Gm-Message-State: APjAAAU61FxMjEhFyROIqi1H+aJN0qAwhruczY/D1D9uV6LCGQMWJOMf /MUleDPAipCJNCnk1onWChz7I6nv4y4= X-Received: by 2002:a2e:8684:: with SMTP id l4mr12225528lji.121.1555972818914; Mon, 22 Apr 2019 15:40:18 -0700 (PDT) Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com. [209.85.208.172]) by smtp.gmail.com with ESMTPSA id s64sm2962411lje.49.2019.04.22.15.40.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Apr 2019 15:40:17 -0700 (PDT) Received: by mail-lj1-f172.google.com with SMTP id h16so11620732ljg.11 for ; Mon, 22 Apr 2019 15:40:17 -0700 (PDT) X-Received: by 2002:a2e:9213:: with SMTP id k19mr11005423ljg.118.1555972817211; Mon, 22 Apr 2019 15:40:17 -0700 (PDT) MIME-Version: 1.0 References: <20190421160600.GA31092@avx2> In-Reply-To: <20190421160600.GA31092@avx2> From: Linus Torvalds Date: Mon, 22 Apr 2019 15:40:00 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] x86_64: uninline TASK_SIZE To: Alexey Dobriyan Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Peter Anvin , Linux List Kernel Mailing , "the arch/x86 maintainers" 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 Sun, Apr 21, 2019 at 9:06 AM Alexey Dobriyan wrote: > > TASK_SIZE macro is quite deceptive: it looks like a constant but in fact > compiles to 50+ bytes. Honestly, if you are interested in improving TASK_SIZE, I'd really like to see you try to go even further than this. TASK_SIZE _used_ to just be a fixed constant, which is why it has that name and why the usage patterns are what they are. But since that isn't true any more, I'd much rather fix the _name_, and I'd much rather fix the nasty complex hidden behavior, rather than just keep the name and keep the behavior, but turning it from an inline macro to a function call. And as Ingo points out, we should be able to just make it a field of its own, instead of that complex dance of TIF_ADDR32 etc. However, I think it would be better if that field would be in "struct mm_struct" instead of Ingo's suggestion of the thread. Because while it's currently a per-thread flag, I think it is only set by execve(), so it always ends up being the same per-mm. No? Also, we could/should just make the existing *users* of TASK_SIZE know that it's no longer a simple constant, so all those functions that use it many times could just do unsigned long task_size = TASK_SIZE; rather than re-compute it multiple times like they do now. In fact, making it a function call in many ways makes things *worse*, although maybe we could at least mark the function "pure" so that gcc would be able to cache the end result. But that would actually be wrong for the sequences that maybe do change the thread flags, so I hate that idea too. Much better to just cache it explicitly in the cases where we see that it's currently generating bad code. Linus