Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp539430pxb; Thu, 30 Sep 2021 11:20:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkBOvoZxhOnKTRkYGND3yknRz6DP4pH719b1RAQ+YnbFqYhx3XYk6gVg5p9TIQzO7YAr0B X-Received: by 2002:a17:90a:4091:: with SMTP id l17mr8141120pjg.138.1633026033214; Thu, 30 Sep 2021 11:20:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633026033; cv=none; d=google.com; s=arc-20160816; b=FwadKvvrXRIaMNAldU6IWtjw2pJDc4eaj8SFWtnY0XShhShDm6X+gTAHJNViMtJP/s pryxumeViOteIqJZJ306+jr5nE3SeS2MiOlNKFMaamZZctdwjd3c5DPC53BkDIL8QY4+ 5j8ObPdXCKLIkna81/assiVhsZOsvK1SXz4IrHGSJwGG2lj9v79ZJdeoxEXNDwE0ldz6 6udLXlOMbZRiFKPScyc8605v85PuVkj3wBqY51XlCC2iJedUR2bK91+WEMguItH6B9cc Br654aqEOe16uh+b6MlwjSn6/wWBzAWGWkuRyjVk9vlqDsHjrC+y4qOdjEejuFljb/1Q tVcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=se4EiZ00KtrBxjyRNVBoxuylYR7GsMp6vwQq86rutw4=; b=rwtjq8Cf+BrN4ZaOLFlXzwRCcSbmYTbuMct7BM4RAPSe+J/4WbUFtSUoGkLNLetnqu QCSuae3mcAbwumfvvJWu5m+adMvmZcuPwy4Cy5A7KyspzoBcM9/JBJHwBJjYD7rRbdpQ tpbxSRy+WOMN3rmiZUBRQnBS2UhnyEFZ2wu9oT/r1QwjAH4ilGVLZkGTfb0kxi//w1Uo 2PyaYr5V5rH6Us8SAowxZq1FHPtsqEafRLINH4KzQVPh5ux9YmPjC+ttxd7SHit86K8v uSE3CKYPLcxY6qyJQm60WxcEyKPqG9vJmaVz5StAb6Id8y7NNp4uiJAolr9/zaTzkj84 cvEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LmRe3QFh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b5si4652757pgt.22.2021.09.30.11.20.18; Thu, 30 Sep 2021 11:20:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LmRe3QFh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351151AbhI3Mzq (ORCPT + 99 others); Thu, 30 Sep 2021 08:55:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351127AbhI3Mzp (ORCPT ); Thu, 30 Sep 2021 08:55:45 -0400 Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DEA0C06176A for ; Thu, 30 Sep 2021 05:54:03 -0700 (PDT) Received: by mail-io1-xd2f.google.com with SMTP id n71so7448385iod.0 for ; Thu, 30 Sep 2021 05:54:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=se4EiZ00KtrBxjyRNVBoxuylYR7GsMp6vwQq86rutw4=; b=LmRe3QFhGUUogxSg/CCyhlKdpk/4mZBmoSK5hvOhVvGWQaUJHDIO0TfaqXzIjmXCBH WUJK6oGSX3BJuE9OChsHTC4d497mmW83oPSjbhhSa0WV1cwNHca532+qYfZD06C9aZPc nHwbB8TVQelA5DeQONC90hxdF4wAp+oq+FfPTqmBsQarPQXGc3XSxCYPNx6aEiLSTyUc CeVa/NfGioZ+5Jww//Z0l5BjKvHnEU80gJDdjfO5iVHzPDoKcMBIDkt3H80Et+ATy9jB 35UKDxLR2R1JJw4eStsmBtW3Ry4P3Gv56B451/2LYKAxbpH1jIqeQqlzPM0eCloQRui1 iZDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=se4EiZ00KtrBxjyRNVBoxuylYR7GsMp6vwQq86rutw4=; b=K5Skp2ZH/2Vw7c807pLwqD4xE1q7xNaotndlsREEYRD5IGJBgrtwCqJ4vBPR6j4W3P WMgvd9QXfLRt/fEIKk3niJ0Rc26t8aF4w8Si8cTz/e7OfEY8wGyDQgMU5JaOlJ9K9xXE u8/UwEQxw93QHHyLtqVmjMQ4y+5pL4EAa+gO/D0esXi2vWV/wjvuko+PmPmUWGFF6JSm tJV1AlykwFHYJj1uWoZzR/Yz9YfUNRazQqr5kZ9DNxn05rkr+DeqFOa1siqQIno8ExXj EXMdrnUfv4/gPqAL3dpRFdMaKWLpKvvh7mGJT8ZaqDNlExvEH0cLUN4drP98oq38J+vk gMDg== X-Gm-Message-State: AOAM533bnViah1Zz4V9AcGr2MMcr9YqOjCrANZgJ1KXpMBF8nhgwsH60 EltlTIKBxOZLSfguUMqA/2k40V6tQerH9ZGUAiQ= X-Received: by 2002:a5d:9493:: with SMTP id v19mr3677984ioj.34.1633006442959; Thu, 30 Sep 2021 05:54:02 -0700 (PDT) MIME-Version: 1.0 References: <20210929115036.4851-1-laoar.shao@gmail.com> <20210929115036.4851-5-laoar.shao@gmail.com> <202109291113.6DE8D6F3D@keescook> In-Reply-To: <202109291113.6DE8D6F3D@keescook> From: Yafang Shao Date: Thu, 30 Sep 2021 20:53:27 +0800 Message-ID: Subject: Re: [PATCH 4/5] kernel: increase the size of kthread's comm To: Kees Cook Cc: Andrew Morton , Petr Mladek , Peter Zijlstra , Valentin Schneider , Mathieu Desnoyers , qiang.zhang@windriver.com, robdclark@chromium.org, Al Viro , christian@brauner.io, Dietmar Eggemann , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 30, 2021 at 2:20 AM Kees Cook wrote: > > On Wed, Sep 29, 2021 at 11:50:35AM +0000, Yafang Shao wrote: > > This patch increases the size of ktread's comm from 16 to 24, which is > > the same with workqueue's, to improve this situation. After this cahnge, > > [...] > > Because there're only a few of kthreads, so it won't increase too much > > memory. > > Even without the performance impact changes, the math here doesn't hold > either, since using kmalloc means there are slabs being allocated to hold > the task "comm"s now (which comes with overhead), and every task added > a pointer to those 16 bytes (i.e. 8 more bytes on 64-bit systems). So > this change, even if there was 0 overhead in using slabs, would be > identical to having just raised TASK_COMM_LEN to 24. 8 byte pointer, > 16 byte allocation == 24 bytes. > Right, thanks for the explanation. I missed the pointer before. What about reusing the kthread_data() to store the the comm if the kthread is not a kworker? struct kthread { ... void *data; // reuse this pointer ... } The logic will be something as follows, if (kthread_is_kworker) { store_worker_desc_into_kthread_data(); // already did in the kernel } else { store_comm_into_kthread_data(); // that is what we should change } And then we modify the proc_task_name() correspondingly. -- Thanks Yafang