From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754944AbcH3W0q (ORCPT ); Tue, 30 Aug 2016 18:26:46 -0400 Received: from skprod2.natinst.com ([130.164.80.23]:41194 "EHLO ni.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751202AbcH3W0p (ORCPT ); Tue, 30 Aug 2016 18:26:45 -0400 Date: Tue, 30 Aug 2016 17:26:12 -0500 From: Josh Cartwright To: Andy Lutomirski Cc: Andy Lutomirski , X86 ML , Borislav Petkov , "linux-kernel@vger.kernel.org" , Brian Gerst , Oleg Nesterov Subject: Re: [PATCH v6 1/3] fork: Add generic vmalloced stack support Message-ID: <20160830222612.GK26784@jcartwri.amer.corp.natinst.com> References: <14c07d4fd173a5b117f51e8b939f9f4323e39899.1470907718.git.luto@kernel.org> <20160824165102.GB22613@jcartwri.amer.corp.natinst.com> MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.6.1 (2016-04-27) X-MIMETrack: Itemize by SMTP Server on US-AUS-MGWOut1/AUS/H/NIC(Release 8.5.3FP6 HF1218|December 12, 2014) at 08/30/2016 05:26:13 PM, Serialize by Router on US-AUS-MGWOut1/AUS/H/NIC(Release 8.5.3FP6 HF1218|December 12, 2014) at 08/30/2016 05:26:13 PM, Serialize complete at 08/30/2016 05:26:13 PM Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="J/zg8ciPNcraoWb6" Content-Disposition: inline X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-08-30_09:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --J/zg8ciPNcraoWb6 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Aug 30, 2016 at 03:01:51PM -0700, Andy Lutomirski wrote: > On Wed, Aug 24, 2016 at 9:51 AM, Josh Cartwright wrote: [..] > >> diff --git a/kernel/fork.c b/kernel/fork.c > >> index 52e725d4a866..05f7ef796fb4 100644 > >> --- a/kernel/fork.c > >> +++ b/kernel/fork.c > >> @@ -158,19 +158,39 @@ void __weak arch_release_thread_stack(unsigned l= ong *stack) > >> * Allocate pages if THREAD_SIZE is >=3D PAGE_SIZE, otherwise use a > >> * kmemcache based allocator. > >> */ > >> -# if THREAD_SIZE >=3D PAGE_SIZE > >> -static unsigned long *alloc_thread_stack_node(struct task_struct *tsk, > >> - int node) > >> +# if THREAD_SIZE >=3D PAGE_SIZE || defined(CONFIG_VMAP_STACK) > >> +static unsigned long *alloc_thread_stack_node(struct task_struct *tsk= , int node) > >> { > >> +#ifdef CONFIG_VMAP_STACK > >> + void *stack =3D __vmalloc_node_range(THREAD_SIZE, THREAD_SIZE, > >> + VMALLOC_START, VMALLOC_END, > >> + THREADINFO_GFP | __GFP_HIGHME= M, > >> + PAGE_KERNEL, > >> + 0, node, > >> + __builtin_return_address(0)); > >> + > >> + /* > >> + * We can't call find_vm_area() in interrupt context, and > >> + * free_thread_stack can be called in interrupt context, so cache > >> + * the vm_struct. > >> + */ > >> + if (stack) > >> + tsk->stack_vm_area =3D find_vm_area(stack); > > > > This is annoying, we end up having to walk the vm_area tree twice (once > > for the allocation, then here to get a handle on area). > > > > Perhaps it's time the vmalloc code learned an allocation API that > > returned the vm_area handle as well. >=20 > Agreed. I may do this once everything else lands. There are at least a few other places that could benefit from this, doing a quick scan of find_vm_area() callers: vmalloc_{32_,}_user() and kasan_module_alloc(). Josh --J/zg8ciPNcraoWb6 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAABCAAGBQJXxgf9AAoJEKp7ZBKwQFArj6AH/1HyPBEjYGU/tuxZH+dV6cVE RlaGioTXbHuWmHvsl2QFLYOov1sbUyysxl87GhsGOwVTC207vZCtU+z4X9bJwUHR LPwY1eg+X5IS6lCriT5gU16Ba6KgU52814tXdGvtZcX4b+ekBH03KFgc6sx2ldYI orlBa2bI8I8SxeVkZcBlCCafRc3G61xlptM23JQDqmfJuKRASFuc71J6KBmuRhBT s8mSy32vp9SZHZ0rAds+COmWLbTS8PyBUTHRP1+ONEKfD1uCF4FTq8SjKCDj88Jc y0X0z+JfLhH3LMvgG7WTwlAXQMTjI0D4jumhOI0Zwsr9kIOsPaOZoKTAvbJhjZE= =oTF4 -----END PGP SIGNATURE----- --J/zg8ciPNcraoWb6--