Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2677839rdb; Tue, 12 Sep 2023 08:54:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFq4JoL1o+z67CvhK3P56LW94npiM6mNIoJ1wGIhmoOR40ep8N4gVai64f9dn3R6caLzpmJ X-Received: by 2002:a17:90a:f494:b0:263:9e9b:5586 with SMTP id bx20-20020a17090af49400b002639e9b5586mr10607968pjb.44.1694534078138; Tue, 12 Sep 2023 08:54:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694534078; cv=none; d=google.com; s=arc-20160816; b=nb6L0OXcLbgr745EaVN1jZvSh63S7/3l/Tuv7SS3BSdRbE/teP5/dCBbHvw02B7Xvk Phjrd/iL2SXdup7GnZdzRCt4B4YTGGXzIeyj0kPliqLb9EOMniLiZpXBcgLjV7yMSjuD mP420PvEm//+/N1hR/v4+O6vnE3lajv14vxVVC1g5JqSoNW0CTo/+arm4TtFnX2TShRZ wXSiD4tf5NlvA80n3YI+6DhZLwDvRA9WTPOW3cr52MEuWJtR5WA6rkVv8QNlCeq2wAtM Y+ntOiO+Q3KmhtHn0YdwTPNOG4ycAPrs1FQM9gWTHF6aBcfDNkfDLBkgXy4GVrL4WeZv 81OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=E73gDifLZlLa6fyXqM8pQWL8tjUrnCmpzLaNBCKImlY=; fh=VDi0j6CzAhGPFtfNxgLLgB7Zn4kZfZXHee+cAWGXhLw=; b=AheDB9Ki0djZWdToRvWsuGjrYqHKrGBTHVhl/604qO8eEHmdA6Z1hSDWuLAQWULfvt wUbzR8zvbDqluL1dknLYH9XuL23q3tZpsPfGNI6T4lFhFIWini/UFqC3MkqCcZjoFvzZ 8hWAdAYDmkxx/Z9HsLcxJwK9q7bU+TraQYYa7ijATp5MsI7tC8ks2dGt+ludZoqMUxDt ngMsyxCxzStFSCZZCZ6VwDOlwWVHwIVvL0AvxMJ6p5mZlbR36paazw393RkeEIwEiTAc +Ook2fq4cP18hrpDeQ0ou6W7nZa3KePJ/Og+DYrv3MSQox17m4wJDz7hpS7ms2ZqNkkc A1vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FCUH6ryY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id bv21-20020a17090af19500b0025c238650d1si7780570pjb.174.2023.09.12.08.54.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 08:54:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FCUH6ryY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 6142A80F7284; Tue, 12 Sep 2023 08:31:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236407AbjILPbd (ORCPT + 99 others); Tue, 12 Sep 2023 11:31:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236408AbjILPbb (ORCPT ); Tue, 12 Sep 2023 11:31:31 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38D5210F3 for ; Tue, 12 Sep 2023 08:31:26 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D147BC43391 for ; Tue, 12 Sep 2023 15:31:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694532685; bh=S4zz5jP4YJxJ2vM+gOrgBKETCnLCuSrQSLBkKGxrHo0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=FCUH6ryYX4GOH62XEZZkwPA6oR50f0GLhw3lVlfwybtdajW/AQ7GaVnKXGZz+oq87 zlp10CbizsUIoggFk+O9UbZF+cVHpaEo850/yfuibZz9hoV5jnMhFoSPJos8OYbeuS qLaU6EeRZxV6OPcHv6czDVSQDTGOEl4w7/4Q6/bk81j13FZ17Jh7kx8zcaBGBsBuN6 hHyjEn5gdHQga1AWIyUc9VTaK9kKmUnTi01O332M9pXbaUCmyqYsXS73x33+hdWyjB UdSOMSibTKgFmb2u1lNDdaCjO9Kle0JOPfDb09YXlAwVliPqIMFq0jdbaRdkXMeBxm zAcp5PkD0w85Q== Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-501be2d45e0so9741094e87.3 for ; Tue, 12 Sep 2023 08:31:25 -0700 (PDT) X-Gm-Message-State: AOJu0YxDNdQzB2d/MJ2A7As/QDYWFB4Ke5VVraY1mH1+3iSW12U8A2yi 8kH082vlNzGqxRysPa0IIsB4pjGct1hXDWy9GQI= X-Received: by 2002:a19:2d58:0:b0:4f8:6abe:5249 with SMTP id t24-20020a192d58000000b004f86abe5249mr9260322lft.3.1694532684005; Tue, 12 Sep 2023 08:31:24 -0700 (PDT) MIME-Version: 1.0 References: <20230615121016.3731983-1-chenhuacai@loongson.cn> <87cyyo9moz.fsf@email.froward.int.ebiederm.org> In-Reply-To: <87cyyo9moz.fsf@email.froward.int.ebiederm.org> From: Huacai Chen Date: Tue, 12 Sep 2023 23:31:12 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] kthread: Rename user_mode_thread() to kmuser_thread() To: "Eric W. Biederman" Cc: Luis Chamberlain , Huacai Chen , Andrew Morton , Kees Cook , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Thomas Gleixner Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 12 Sep 2023 08:31:39 -0700 (PDT) X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Hi, Eric, On Tue, Sep 12, 2023 at 9:59=E2=80=AFAM Eric W. Biederman wrote: > > Huacai Chen writes: > > > Hi, all, > > > > Friendly ping again? > > > > > > Huacai > > > > On Sun, Jul 23, 2023 at 10:13=E2=80=AFPM Huacai Chen wrote: > >> > >> Hi, Eric, > >> > >> On Tue, Jul 18, 2023 at 8:43=E2=80=AFPM Huacai Chen wrote: > >> > > >> > Hi, Luis, > >> > > >> > On Sat, Jul 1, 2023 at 7:25=E2=80=AFAM Luis Chamberlain wrote: > >> > > > >> > > On Sun, Jun 25, 2023 at 04:55:33PM +0800, Huacai Chen wrote: > >> > > > Friendly ping? > >> > > > >> > > You want to cc the folks who Nacked your patch. Until then, this > >> > > probably can't go further. > >> > Thank you very much. Eric and Andrew are already in the CC list, so > >> > add Thomas now. > >> > > >> > My brain is a little old-fashioned so I insisted that "a thread > >> > without mm_struct should be a kernel thread" in the previous patch. > >> > Unfortunately this makes Eric and Thomas unhappy, I'm very sorry for > >> > that. > >> > > >> > During the discussion of the previous patch I know I made some > >> > mistakes about some basic concepts, but I also found the name > >> > "user_mode_thread()" is somewhat confusing. I think rename it to > >> > kmuser_thread() is better, because: > >> > 1, it identify init and umh as user threads; > >> > 2, it points out that init and umh are special user threads that run > >> > in kernel mode before loading a user program. > >> > > >> > Sorry for my rudeness again. > >> Excuse me, but could you please tell me what your opinion is. In my > >> opinion a typical user thread is created by > >> pthread_create()/sys_clone(), it is better to distinguish typical user > >> threads from init and umh. > > If we want to emphasize that it is a kernel concept I am happy with > renaming user_mode_thread to user_mode_task. That is more accurate. > > But all threads from the kernel perspective are tasks. Further > all threads have times when they run code in the kernel (aka system > calls) and times when they run code in userspace. > > Linux kernel tasks created with user_mode_thread() are exactly like > other user mode tasks, and have all treated exactly the same was by the > system as any the tasks created by pthread_create() and sys_clone(). > > The only oddity is that there is no user mode code to execute until > after execve is called. > > When running code in the kernel, user space threads never logically > do not use the user space page tables. > > They are different in some significant ways from tasks created with > kernel_thread(). Tasks created with kernel_thread do not support > calling execve, among other things. > > But deeply and fundamentally I think you are trying to make a > distinction that is not there. All user space threads run code > in the kernel before they run code in userspace. Most often > it is from the system calls fork/clone/exec. For init and umh it > is effectively a special dedicated system call that includes > an execve. > > Let me ask what difference are you trying to high light that callers > of user_mode_thread need to be aware of? What problem in thinking > do you think that the name user_mode_thread creates? I am asking > because I might just be missing your point. 1, My first key point is =E2=80=9Cintuition=E2=80=9D, by intuition sys_clone()/pthread_create() creates a user thread, but init and umh are more or less different (special user thread). 2, My second key point is "symmetry", for symmetry =E2=80=98kernel_thread= =E2=80=99 is a counterpart of =E2=80=98user_thread=E2=80=99, while =E2=80=98user_mode_th= read=E2=80=99 is a counterpart of =E2=80=98kernel_mode_thread=E2=80=99. If we keep the =E2=80= =98kernel_thread=E2=80=99 name, then we can only rename the =E2=80=98user_mode_thread=E2=80=99. As di= scussed before, init and umh are user threads, but they are special user threads run in kernel mode before kernel_execve, so I want to rename it to =E2=80=98user_thread=E2=80=99 with a 'km' prefix, so =E2=80=98kmuser_= thread=E2=80=99. Huacai > > Eric