Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp814923ybz; Fri, 1 May 2020 09:02:32 -0700 (PDT) X-Google-Smtp-Source: APiQypIw184e06+aYAjHS8DZThMrVNZJWvCgtxJbV0piKiF2BO61OwtXj88AwoHW4a4feSFuXVzA X-Received: by 2002:a17:906:f1c3:: with SMTP id gx3mr3852423ejb.25.1588348952274; Fri, 01 May 2020 09:02:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588348952; cv=none; d=google.com; s=arc-20160816; b=KVcCyqIhukdhXjVU20iGBbNsfp1qI7nZWY7ACRVXy2RmCoLMRO/fxCayCPh11zkqXj qfSRzr9QqoyNI6o7Y2IJrJDhfEfMDvoNaYQkBL9hp98GrTDWySLjihIVrQOYS9iaNOjE TAFNMkRqW8psPepqNnAUw5Lp6C2j4Kqvc13t9uS0aR79GC9i1xjmY93YSRUZ8SIMXwt7 BzylvCOC3Sps1hAV6ZZI5AVMa+N3zXmA6W9nkTCl3giXZ6qNgbSfbhRudqGswXc8Z2Hs Fi2nt9zbcOSkjgB9+WjancFfjoKcJjjo6/pk40JTigpMEMdNtWz2Mio88D26DVQoNyuX cUzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=oejOytCmmk4sUnMYZ0Rc49Z2TSc9ghICr5vNI8ETbKA=; b=cJ2HvOivrPJz1Ays9Zsrms1k3DnJcieBAZa34FLW6FSc+5t3Q8reB64qvD/fXUbf9Y oTdvjOZjKZAQenshfKREpZDfixpvNdXKT3J7daZMv63uwvXdRn938d9ta+hBTEmIpUvA YU319zoDyUlljPM3siHa6/LvLJP5DZMO3AdOo7RjeENXZys2XgG6n7Xwtwj3zCWPAN1s SaocOjp+fh8y+ufX/N2pd4IGbIKxd01cbvI6QW6cxWkYhGA3s3FTcibdQeuTYlXhlRMX rCEpMYwIl2vyOEvPZbwVoo0qEGKWVuUS8ccy5pD52BxSP8WTzElQjuDUbz2LE8MQymzL DrAA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i14si2118072eja.57.2020.05.01.09.02.06; Fri, 01 May 2020 09:02:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728495AbgEAQBz (ORCPT + 99 others); Fri, 1 May 2020 12:01:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729975AbgEAQBz (ORCPT ); Fri, 1 May 2020 12:01:55 -0400 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00::f03c:91ff:fe50:41d6]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DEB1C061A0C for ; Fri, 1 May 2020 09:01:55 -0700 (PDT) Received: by fieldses.org (Postfix, from userid 2815) id D94141504; Fri, 1 May 2020 12:01:53 -0400 (EDT) From: "J. Bruce Fields" To: Linus Torvalds Cc: linux-nfs@vger.kernel.org, Jeff Layton , David Howells , Tejun Heo , Shaohua Li , Oleg Nesterov , linux-kernel@vger.kernel.org, "J. Bruce Fields" Subject: [PATCH 1/4] kthreads: minor kthreadd refactoring Date: Fri, 1 May 2020 12:01:49 -0400 Message-Id: <1588348912-24781-2-git-send-email-bfields@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1588348912-24781-1-git-send-email-bfields@redhat.com> References: <1588348912-24781-1-git-send-email-bfields@redhat.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: "J. Bruce Fields" Trivial refactoring, no change in behavior. Not really necessary, a separate function for the inner loop just seems a little nicer to me. Signed-off-by: J. Bruce Fields --- kernel/kthread.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/kernel/kthread.c b/kernel/kthread.c index bfbfa481be3a..4217fded891a 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c @@ -578,6 +578,24 @@ int kthread_stop(struct task_struct *k) } EXPORT_SYMBOL(kthread_stop); +void kthread_do_work(void) +{ + spin_lock(&kthread_create_lock); + while (!list_empty(&kthread_create_list)) { + struct kthread_create_info *create; + + create = list_entry(kthread_create_list.next, + struct kthread_create_info, list); + list_del_init(&create->list); + spin_unlock(&kthread_create_lock); + + create_kthread(create); + + spin_lock(&kthread_create_lock); + } + spin_unlock(&kthread_create_lock); +} + int kthreadd(void *unused) { struct task_struct *tsk = current; @@ -597,20 +615,7 @@ int kthreadd(void *unused) schedule(); __set_current_state(TASK_RUNNING); - spin_lock(&kthread_create_lock); - while (!list_empty(&kthread_create_list)) { - struct kthread_create_info *create; - - create = list_entry(kthread_create_list.next, - struct kthread_create_info, list); - list_del_init(&create->list); - spin_unlock(&kthread_create_lock); - - create_kthread(create); - - spin_lock(&kthread_create_lock); - } - spin_unlock(&kthread_create_lock); + kthread_do_work(); } return 0; -- 2.26.2