Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2266183yba; Mon, 22 Apr 2019 03:41:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqyEI1eIjNtAMQu9gHtjycSBgcc8Rt8kOv5yqCg8D6JjpHh4qZo/BMAQP9QmAZN5Vtp8wQ7S X-Received: by 2002:a62:5707:: with SMTP id l7mr20327590pfb.205.1555929673201; Mon, 22 Apr 2019 03:41:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555929673; cv=none; d=google.com; s=arc-20160816; b=UwXUffWmEyCZDSc/PT9fLaIkSF6X1v8YkyP+4bESr1WhHkTuuK94QCPOqOnrA4m0St ydWee1Vg5oU4NVYK/MO8JgbZQJsrC59ctXOm8MWeaHnyUkl50gbQYGORM7/Hqp/nw8ZT 8TY6DJTg2BaKZvQ3gl2zUJixExcU0TiScDYgpM6ysl3NQKIynVWP3+9MytoCU2jYPsUy RkKTDkuFRPDMMsR34AAnemrIojZseqtpr6/BBRMwVZMgaN8AxzpFFpjAPg6NaKxQSsfe B8Umhst69xjigQdbVmX9qCSNJzdisVtqrb9grzuQ4XhnFYPyHtuCNggZ7nlytso4EY7J FMrQ== 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:dkim-signature; bh=zyMQ+eyBXo2LZ4GuH7kHJyfZneSPy6Q384j2ybq1soc=; b=GE9wCm5vOIi0PhqdvSJgIikgMSAQf1EemymfqQU/JrhpN/UTWpbE9YvmlCHOi4JMU1 oFh3ATHFqpydx663Kbh1wg1M/o4ZXEWDSMWzv3haDOg+7B+vgyPLkobYSaqhpdSDKDnx DmJI/Ggtm9U/HXPqv5anEQnby7fsNyGgtx1HXTYBn6u2z09KxYp2gSQ4ultIweU+Ef+u pszzKU6dVomE4WmZvT4f5ViEzdLhhvG0RXw7p/bDR21YGeAhUju7cBgDYaGpq7Nyuwu5 nh2QCI/64FmWdHkfopzV69g5W+DilfiFpzyIsiC8HIiIEh1XElUuvSUbfFMZ3jTDkEO5 4uBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=ZyozIE9F; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x23si12515992plr.48.2019.04.22.03.40.33; Mon, 22 Apr 2019 03:41:13 -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=fail header.i=@gmail.com header.s=20161025 header.b=ZyozIE9F; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727096AbfDVKez (ORCPT + 99 others); Mon, 22 Apr 2019 06:34:55 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:54189 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727014AbfDVKez (ORCPT ); Mon, 22 Apr 2019 06:34:55 -0400 Received: by mail-wm1-f67.google.com with SMTP id q16so13923710wmj.3 for ; Mon, 22 Apr 2019 03:34:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=zyMQ+eyBXo2LZ4GuH7kHJyfZneSPy6Q384j2ybq1soc=; b=ZyozIE9FInXiUNKlwZfru+qlaypsIpOnn5VC3ZnDvPY4L6Cpcif1OB0iD2yxX8R74y eQ67n2Oa+lwANYt065QzvtS03Rq7fPxZpZGsI5TudvzDPRlUML5ZQDoYCaVWlzgcadB4 xmSRzwjZcoCxJc8e12U1IenRbh+hbL2JLRp3QpYKpaXJ58RCHDxst5jJ7ozbQU5b0XJt 9JnvLXePqrA2mLgyPPKlf4Uh+fRfHdtZg8rr3Xk5CGN1TAvlTJvTMaDAOB98911dWe39 hldRPNac6jjKMMDx6eOk1DSPcfV7l1bFhLd0Qb2I4nsnVZKEx5ADdpo8PZym4EHR5wic l22A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=zyMQ+eyBXo2LZ4GuH7kHJyfZneSPy6Q384j2ybq1soc=; b=YMkM04TuIB1Oh35EAr6aXtwi43GS+vhF+GAYmUztU42dLD2DnLnuKFnxMervgjwak7 RE7e2q/WVcUhn3wX+UEOhEEz+BEUYa1mFs8yzVSd3JJurIY5JWBW5SMGDR01njQ87zOQ FBqLaJd3dn7G9Tqy7in463oTS5zvi44oO21xYzMkmTlAgtYEXw0LIbVBn0jP0teYem67 oxfYqrFM2UmI+hn4l2Y1lk4vwkhTFSsRlMLdxd2TGFICx3F4GrmGom2ARMIu8lV4uhJL tNhe/QZvqRdtyVyf+UqYTBAz7bIBsr36uRQqPXihWo3EoY0agx1kc0xbNoSOR8rwlPtK KyZg== X-Gm-Message-State: APjAAAWya//thYSS/WA3vbhNfua+QJBINKVAJes2pEBv31YNP1qL2SxM 7UHNCWzEEeQkjmWfEsN5XoS6Dx1M X-Received: by 2002:a1c:7208:: with SMTP id n8mr12451725wmc.46.1555929293362; Mon, 22 Apr 2019 03:34:53 -0700 (PDT) Received: from gmail.com (2E8B0CD5.catv.pool.telekom.hu. [46.139.12.213]) by smtp.gmail.com with ESMTPSA id i17sm13060467wrs.44.2019.04.22.03.34.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Apr 2019 03:34:52 -0700 (PDT) Date: Mon, 22 Apr 2019 12:34:49 +0200 From: Ingo Molnar To: Alexey Dobriyan Cc: 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 Subject: Re: [PATCH] x86_64: uninline TASK_SIZE Message-ID: <20190422103449.GA75723@gmail.com> References: <20190421160600.GA31092@avx2> <20190421182842.GD35603@gmail.com> <8B42CD57-9343-4234-A96D-80337BFFDF0E@zytor.com> <20190421211007.GA30444@avx2> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190421211007.GA30444@avx2> 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 * 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. Thanks, Ingo