Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2535435yba; Mon, 22 Apr 2019 08:31:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqzonFgRjHuLXz94zuU1a9gJDA5QLeLD0INIQ3S2iRWISdCxmS9A+uQfqF+mXv+6WRzqTbga X-Received: by 2002:a63:b48:: with SMTP id a8mr18434566pgl.368.1555947068483; Mon, 22 Apr 2019 08:31:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555947068; cv=none; d=google.com; s=arc-20160816; b=VkAtKqSa7NV77Gn7y9YL9xrji4F0AvCyv1NECaKvp7YySj2/TPXRMe7xhQMu3lmYbp El/fQEtmu3umd6ZP2gb5Lqy9NAuu+Ne1t7ZInxIa75mP6upLfzMyHkKjB7pIVhH+H+5e +iBS21SLMJSv9lgkvXXxAOCiTHT6RAaSaEm7TWlJ7tbi2i2irWNRv72hI2c9MIGhstL4 3cDe9dt/y8UeQHkcFzp01jQpAWANkeyaGIyUYltEJL4mkivZkmRvQT3UDzNH2yvnr+fN fByuOJDAAOxyFpCwDi18bpQ6ifdBK0Bot1ZWMcezizYxkOyyK7xfb/oxApX/yLBmeyQD j0FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=ArldgXyAXu7r8SaMqXs/zXI4veqAyV+eA/nB9PbZS/s=; b=jMKyvcLGK+7nOkgCen5APhBbIqyZdkl+wrqXt7rL3MecJ3WbgxPpe7JDGtnnTesI/2 8aKlb4hj/rL6sQyA070tCyhFb4CRjazWVncHaLbQ26REIdGIHI4JX9F4sSy16lzd/2Ij v3bnvDG9YkgddZU75GUd8kbYdA76FwcLK8tsJiZspZKEAAtBeknXX8sDsoTGw8pTBzhA W48Q3hT/zcqeUJ9yodlMEu4b3MVWjEoHGRRjCeL8dcJ+YhEsi5JLw6YPxi0FtITxZadu RE7xex+P57BvJzzkB1b0Xzu5LpPUQzIoIiofgDdcj766u0QK9wW+jZxWFj7BEc0f8Lf5 qhlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=WDKUOxmZ; 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 m7si13355350pls.114.2019.04.22.08.30.49; Mon, 22 Apr 2019 08:31:08 -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=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=WDKUOxmZ; 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 S1727660AbfDVOap (ORCPT + 99 others); Mon, 22 Apr 2019 10:30:45 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:36747 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726098AbfDVOao (ORCPT ); Mon, 22 Apr 2019 10:30:44 -0400 Received: by mail-pl1-f193.google.com with SMTP id ck15so5917834plb.3 for ; Mon, 22 Apr 2019 07:30:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=ArldgXyAXu7r8SaMqXs/zXI4veqAyV+eA/nB9PbZS/s=; b=WDKUOxmZ+s+UMYz7/2matkO3h5JNNIeZBIR4EF0gbs08iTuma04lqp9OR0Uow7a9uK y3X+e98D7PlBsxT6y82ShVC4FT3QRsrSand1SOrKRqu7ovJhqN8CdQVZyZGdhnQcVcD/ qo6LDz/7I/MkfwfHiX+YO6hzYfem6kMxIGs7rfXlif0pgsRLGtaedQsOZsTpbXHViD0/ kQCDwU2vsYU+qMEUFcwbkrIbVkN1DGXb08PypdjAgid881lIUszjPiru1N7pnxgkiaqB ZJHRG89TFkIx6CA7Sk7Ep3pQrezexCvEkZL9A75ndFVxcebEfSR66UthSLHySWDga4pR //2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=ArldgXyAXu7r8SaMqXs/zXI4veqAyV+eA/nB9PbZS/s=; b=fMfI+Ab4/MlBOSvPOXuGaZOvZ4g25lSpL7lXcptKMrT9bGzXPCa8b8Ply3dNUh/lkt ssun7UC16uLVn2eocftFc5RJU6zIGNf3XEl/7wIo/Q66tti80qWOug7/p71JvlwP4ybb 9VqT+k0pAPHcKfDV7bFY4OQ1CYfhl+QN2juXTzYyuypPxdU6/wY53HkeH2TFa+FfbPg6 LawRgwcQGnRafoNzjhfqwHi1eP6KYkweVfjigb73AuvMcoWM6+R0W/l/8qgP/aH7SfcB S8ze1y2dSKfabRmSluDUCO+W0srxnYODl4VvsgEfEDtKCgkZ71/Qs33R6OQq1eFGV9a/ XLQQ== X-Gm-Message-State: APjAAAXl2W7CPKTvjvd+bmxwCkXOGlBHdpWy76K2ax4kLqTo/h6CTn0U HFuHeiwPjXlVE14sJ79myhUDhw== X-Received: by 2002:a17:902:1103:: with SMTP id d3mr14373615pla.247.1555943444060; Mon, 22 Apr 2019 07:30:44 -0700 (PDT) Received: from ?IPv6:2601:646:c200:1ef2:c48c:1647:d18c:78c5? ([2601:646:c200:1ef2:c48c:1647:d18c:78c5]) by smtp.gmail.com with ESMTPSA id j6sm16858630pfe.107.2019.04.22.07.30.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Apr 2019 07:30:42 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (1.0) Subject: Re: [PATCH] x86_64: uninline TASK_SIZE From: Andy Lutomirski X-Mailer: iPhone Mail (16E227) In-Reply-To: <20190422103449.GA75723@gmail.com> Date: Mon, 22 Apr 2019 07:30:40 -0700 Cc: Alexey Dobriyan , hpa@zytor.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, linux-kernel@vger.kernel.org, x86@kernel.org, Andy Lutomirski , Peter Zijlstra , Linus Torvalds , Al Viro Content-Transfer-Encoding: 7bit Message-Id: References: <20190421160600.GA31092@avx2> <20190421182842.GD35603@gmail.com> <8B42CD57-9343-4234-A96D-80337BFFDF0E@zytor.com> <20190421211007.GA30444@avx2> <20190422103449.GA75723@gmail.com> To: Ingo Molnar Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Apr 22, 2019, at 3:34 AM, Ingo Molnar wrote: > > > * Alexey Dobriyan wrote: > >>>>> +++ b/arch/x86/kernel/task_size_64.c >>>>> @@ -0,0 +1,9 @@ >>>>> +#include >>>>> +#include >>>>> +#include >>>>> + >>>>> +unsigned long _task_size(void) >>>>> +{ >>>>> + return test_thread_flag(TIF_ADDR32) ? IA32_PAGE_OFFSET : >>>> TASK_SIZE_MAX; >>>>> +} >>>>> +EXPORT_SYMBOL(_task_size); >>>> >>>> Good idea - but instead of adding yet another compilation unit, why not >>>> >>>> stick _task_size() into arch/x86/kernel/process_64.c, which is the >>>> canonical place for process management related arch functions? >>>> >>>> Thanks, >>>> >>>> Ingo >>> >>> Better yet... since TIF_ADDR32 isn't something that changes randomly, >>> perhaps this should be a separate variable? >> >> Maybe. I only thought about putting every 32-bit related flag under >> CONFIG_COMPAT to further eradicate bloat (and force everyone else to >> keep an eye on it, ha-ha). > > Basically TIF_ADDR32 is only set for a task if set_personality_ia32() is > called, which function is called in the following circumstances: > > - arch/x86/ia32/ia32_aout.c:load_aout_binary() > > This is in exec(), when a new binary is loaded for the current task, > via search_binary_handler() and exec_binprm(). Ordering is > synchronous, AFAICS there can be no race between TASK_SIZE users and > the set_personality_ia32() call which is always for the current task. > > - in COMPAT_SET_PERSONALITY(), which through macro detours ends up being > in SET_PERSONALITY2(), which is used in fs/compat_binfmt_elf.c's > load_elf_binary(), used in a similar fashion in exec() as the AOUT > case above. One particular macro detour of note is that > fs/compat_binfmt_elf.c #includes fs/binfmt_elf.c and re-defines the > personality setting method to map to set_personality_ia32(). > > When set_personality_ia32() is called then TIF_ADDR32 is set > unconditionally, without any Kconfig variations. > > TIF_ADDR32 is cleared: > > - In set_personality_64bit(), when a 64-bit binary is loaded via > fs/binfmt_elf.c. > > - It also defaults to clear in the init task, which is inherited by the > initial kernel threads and any user-space task they might end up > executing. > > So the conclusion is that IMO we can safely put TASK_SIZE into a new > thread_info()->task_size field, and: > > - change ->task_size to the 32-bit address space in > set_personality_ia32() > > - change ->task_size to teh 64-bit address space in the init task and in > set_personality_64bit(). > > This should cover it I think, unless I missed something. > Are there really enough TASK_SIZE users to justify any of this?