From patchwork Thu Oct 15 13:01:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 11839311 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 50B6861C 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 9791522255 for ; Thu, 15 Oct 2020 13:02:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9791522255 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) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id AEC5F6B0062; Thu, 15 Oct 2020 09:01:59 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org 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-Original-To: linux-mm@kvack.org 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-Spam-Summary: 1,0,0,,d41d8cd98f00b204,linmiaohe@huawei.com,,RULES_HIT:30012:30054,0,RBL:45.249.212.35:@huawei.com:.lbl8.mailshell.net-64.95.201.95 62.18.2.100;04yr89efmbhnnmpwcser3z1zqekyfyc4s3phutfsrunqmo9xn4j73b6dyz8fqeu.9tcumeszhg9f5q4bf5gq1snii4g8paq9q3bi9wc6p9fceqqzbewym4hwc4wb6f7.k-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none 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 X-Originating-IP: [10.175.104.175] X-CFilter-Loop: Reflected 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 Acked-by: Minchan Kim Reviewed-by: Sergey Senozhatsky --- 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]); } /*