From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A0BDC433E7 for ; Thu, 15 Oct 2020 13:02:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C1E1422258 for ; Thu, 15 Oct 2020 13:02:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C1E1422258 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B3CA06B005D; Thu, 15 Oct 2020 09:01:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AEC5F6B0062; Thu, 15 Oct 2020 09:01:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9DB076B0068; Thu, 15 Oct 2020 09:01:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0202.hostedemail.com [216.40.44.202]) by kanga.kvack.org (Postfix) with ESMTP id 71BAE6B005D for ; Thu, 15 Oct 2020 09:01:59 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id F2BEC180AD81A for ; Thu, 15 Oct 2020 13:01:58 +0000 (UTC) X-FDA: 77374172358.23.quill30_42113c027214 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id B593137608 for ; Thu, 15 Oct 2020 13:01:58 +0000 (UTC) X-HE-Tag: quill30_42113c027214 X-Filterd-Recvd-Size: 2045 Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf28.hostedemail.com (Postfix) with ESMTP for ; Thu, 15 Oct 2020 13:01:57 +0000 (UTC) Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 98E657D511BA10B261F0; Thu, 15 Oct 2020 21:01:29 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.487.0; Thu, 15 Oct 2020 21:01:19 +0800 From: Miaohe Lin To: , , , CC: , , Subject: [PATCH] zsmalloc: Rework the list_add code in insert_zspage() Date: Thu, 15 Oct 2020 09:01:07 -0400 Message-ID: <20201015130107.65195-1-linmiaohe@huawei.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.104.175] X-CFilter-Loop: Reflected Content-Transfer-Encoding: quoted-printable 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: Rework the list_add code to make it more readable and simplicity. Signed-off-by: Miaohe Lin --- mm/zsmalloc.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 918c7b019b3d..b03bee2e1b5f 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -730,13 +730,10 @@ static void insert_zspage(struct size_class *class, * We want to see more ZS_FULL pages and less almost empty/full. * Put pages with higher ->inuse first. */ - if (head) { - if (get_zspage_inuse(zspage) < get_zspage_inuse(head)) { - list_add(&zspage->list, &head->list); - return; - } - } - list_add(&zspage->list, &class->fullness_list[fullness]); + if (head && get_zspage_inuse(zspage) < get_zspage_inuse(head)) + list_add(&zspage->list, &head->list); + else + list_add(&zspage->list, &class->fullness_list[fullness]); } =20 /* --=20 2.19.1