From patchwork Tue Oct 25 03:11:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13018437 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B85DC38A2D for ; Tue, 25 Oct 2022 03:11:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1C56780008; Mon, 24 Oct 2022 23:11:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 14E5180007; Mon, 24 Oct 2022 23:11:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F311480008; Mon, 24 Oct 2022 23:11:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E0A2D80007 for ; Mon, 24 Oct 2022 23:11:55 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9F31B14076F for ; Tue, 25 Oct 2022 03:11:55 +0000 (UTC) X-FDA: 80057997390.02.64C9873 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf20.hostedemail.com (Postfix) with ESMTP id 3DF5D1C0009 for ; Tue, 25 Oct 2022 03:11:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666667514; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=WHhKtOeyUECAlor2iEgXFgtH6f72JWi4N4xTwfFo+LI=; b=BNnCITz/W0mT4Vusru7PQb9crfep0YA4YDUJ8mA7kZ/FTwBOM1Bd6QA5WFe70QkWPHiFHv gu7EIbnu9RbKDhHggpefKOE1U8FyxiNfwtggT4xd+fuQYvWVkm4lr5zQmTqX5UwAVTMB2K J8eQO5XFAK0jtBtLiXk4ofOAAoOOqMg= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-611-ZflSR3d1M_S-pprjMWXF1A-1; Mon, 24 Oct 2022 23:11:50 -0400 X-MC-Unique: ZflSR3d1M_S-pprjMWXF1A-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CB2E61C068C3; Tue, 25 Oct 2022 03:11:49 +0000 (UTC) Received: from localhost (ovpn-12-35.pek2.redhat.com [10.72.12.35]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 04FC617582; Tue, 25 Oct 2022 03:11:48 +0000 (UTC) Date: Tue, 25 Oct 2022 11:11:45 +0800 From: Baoquan He To: linux-kernel@vger.kernel.org Cc: Dennis Zhou , Tejun Heo , Christoph Lameter , Andrew Morton , linux-mm@kvack.org Subject: [PATCH v2 2/8] mm/percpu: use list_first_entry_or_null in pcpu_reclaim_populated() Message-ID: References: <20221024081435.204970-1-bhe@redhat.com> <20221024081435.204970-3-bhe@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221024081435.204970-3-bhe@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666667515; a=rsa-sha256; cv=none; b=rvc4j3eAoJHIU+mC5afPhDNdwWINjVamyEAN+cuBrndbZGOk2PmciR/1InWFuQnQKVO0qj ISkEgBafjvZDcbvxnx1ERnBHuvPDqngz3nvk1Vh1dS0ruhOikwwEoVRfqfw1+hVlf/sAoD r8Ff19kKdDKE23h2yEBbTZgZtSxPT3I= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="BNnCITz/"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf20.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666667515; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WHhKtOeyUECAlor2iEgXFgtH6f72JWi4N4xTwfFo+LI=; b=I8FDhv8OZjp1wurvOXH6z0yc38MmYAa9ha+5pxC/sds6G2WPXfnfY2shvIZqidwTMn1+0M NSbCXMX0zJIHeIwfK3gAZN7vTDDmLBdncsuyXDkHqRsj105c0x5qqiBfzAuD9iW+MX/ISU Sp6/kXDA3DL6DC8RK9q51Fv25U8OPSU= X-Rspamd-Queue-Id: 3DF5D1C0009 Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="BNnCITz/"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf20.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com X-Rspamd-Server: rspam12 X-Rspam-User: X-Stat-Signature: x8jyxff1xhme5bgwpup5o4bwtkdu6bbu X-HE-Tag: 1666667515-414134 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: To replace list_empty()/list_first_entry() pair to simplify code. Signed-off-by: Baoquan He Acked-by: Dennis Zhou --- v1->v2: - Add parentheses around assignment in the while condition. This mutes the lkp warning. mm/percpu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/percpu.c b/mm/percpu.c index 26d8cd2ca323..841bb93aaae6 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -2143,9 +2143,9 @@ static void pcpu_reclaim_populated(void) * other accessor is the free path which only returns area back to the * allocator not touching the populated bitmap. */ - while (!list_empty(&pcpu_chunk_lists[pcpu_to_depopulate_slot])) { - chunk = list_first_entry(&pcpu_chunk_lists[pcpu_to_depopulate_slot], - struct pcpu_chunk, list); + while ((chunk = list_first_entry_or_null( + &pcpu_chunk_lists[pcpu_to_depopulate_slot], + struct pcpu_chunk, list))) { WARN_ON(chunk->immutable); /*