From patchwork Sun Apr 5 13:06:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenqiwu X-Patchwork-Id: 11474699 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 7D1FC92A for ; Sun, 5 Apr 2020 13:06:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 45A8F20672 for ; Sun, 5 Apr 2020 13:06:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JQzG+GOX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 45A8F20672 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6CA8B8E000A; Sun, 5 Apr 2020 09:06:48 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 67BF08E0009; Sun, 5 Apr 2020 09:06:48 -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 56A438E000A; Sun, 5 Apr 2020 09:06:48 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0008.hostedemail.com [216.40.44.8]) by kanga.kvack.org (Postfix) with ESMTP id 408B48E0009 for ; Sun, 5 Apr 2020 09:06:48 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 04814801ABF3 for ; Sun, 5 Apr 2020 13:06:48 +0000 (UTC) X-FDA: 76673826096.02.need52_11fa1a974f1f X-Spam-Summary: 2,0,0,a77c3c192daac04a,d41d8cd98f00b204,qiwuchen55@gmail.com,,RULES_HIT:41:69:355:379:541:800:960:973:988:989:1260:1345:1535:1542:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3354:3866:4321:5007:6114:6261:6642:6653:7576:9413:10004:11026:11473:11658:11914:12296:12297:12438:12517:12519:12555:12679:12895:12986:14096:14181:14394:14721:21080:21444:21451:21627:21666:30012:30054,0,RBL:209.85.216.65:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.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:23,LUA_SUMMARY:none X-HE-Tag: need52_11fa1a974f1f X-Filterd-Recvd-Size: 5211 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Sun, 5 Apr 2020 13:06:47 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id v13so5299912pjb.0 for ; Sun, 05 Apr 2020 06:06:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=sNp/aIJc8rUrEGeiVjOU7fQrsCYzE6bEA7xpPG2YSDE=; b=JQzG+GOXNhlRZjZuRGB8EPsFr3L9ZUrMRbR7xt7zbZDV1k8D1XAJCUYgnhp4BuO6lN TA+0uSBWMP8XbfPtYRWOVmJ3qOypSkS63QI8NiVDDA5vTDnOt8pmM64QGI6So4EwOLma oWy77Q3Wkba6lsLDeeUCYI/wJc0i7seVvBjoVCgVJtxwSOkHPZOi6M+ITNPlKKgV9m6V 1p3ZYLuBTZJP8zyTIohNsi/yG6FBWdMKBJrQ4eYNFqnCtZdxfi2pK+jASo9IXuidt0qp V/+kxOz4HBbOlM0rYPnpVO2dkepxPiRm/RcJWBM4NUVo7ttu7FgnIiwwbixnaJmoUi96 bgag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=sNp/aIJc8rUrEGeiVjOU7fQrsCYzE6bEA7xpPG2YSDE=; b=XFNJLMXDxSn5mNClelAP71rXBNZpg3+/t9x5CuM0rRLPBSmOf5EUAXJ9wjLE525dlh 8nIvkCBg5lz2AIG1n8GgwlEjMoos4qRrJEMZN16YLkljQX6KAKpscnVQJvVe4yPqMC49 FlR6ZQ0H8Jqpnsx5n3fZdFjdLxQ/ENt33lYzNNCar5qvj5uBjv+XeH023q5YP/nR73u3 2mqdvNaCluiyAQFHT06iv/DLyYBGfgQkWzi32hJCrEVJOsRf4iPNtXInfOLR7I5CEjLF Kdsyw3oZxWb+yeuVUWjJIkRdg9tr+QSU8Iu1q/eV/1FOq8I3UsZXXOod4fUbeVmF3y3E 08Qw== X-Gm-Message-State: AGi0PuZqLF+SS5xve0F1A+Kg2GA20BnaZP4fP0kOR/SnJOoDljWt1F/C NKHDmjS78i1Yjrbdbp6FTvc= X-Google-Smtp-Source: APiQypKJ8cmQyHxKZ76QxZjxmWxW7WlFKt+jWZJ4WUXhVNFvZ8ki3klw2QbtsrZ4wxKYBuuw64gQlQ== X-Received: by 2002:a17:902:8b82:: with SMTP id ay2mr618905plb.153.1586092006589; Sun, 05 Apr 2020 06:06:46 -0700 (PDT) Received: from localhost ([43.224.245.179]) by smtp.gmail.com with ESMTPSA id z17sm9501125pff.12.2020.04.05.06.06.45 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Sun, 05 Apr 2020 06:06:46 -0700 (PDT) From: qiwuchen55@gmail.com To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, chenqiwu Subject: [PATCH] mm/swapfile: use list_{prev,next}_entry() instead of open-coding Date: Sun, 5 Apr 2020 21:06:41 +0800 Message-Id: <1586092001-21769-1-git-send-email-qiwuchen55@gmail.com> X-Mailer: git-send-email 1.9.1 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: From: chenqiwu Use list_{prev,next}_entry() instead of list_entry() for better code readability. Signed-off-by: chenqiwu --- mm/swapfile.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index 273a923..6900368 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -3653,7 +3653,7 @@ static bool swap_count_continued(struct swap_info_struct *si, spin_lock(&si->cont_lock); offset &= ~PAGE_MASK; - page = list_entry(head->lru.next, struct page, lru); + page = list_next_entry(head, lru); map = kmap_atomic(page) + offset; if (count == SWAP_MAP_MAX) /* initial increment from swap_map */ @@ -3665,13 +3665,13 @@ static bool swap_count_continued(struct swap_info_struct *si, */ while (*map == (SWAP_CONT_MAX | COUNT_CONTINUED)) { kunmap_atomic(map); - page = list_entry(page->lru.next, struct page, lru); + page = list_next_entry(page, lru); BUG_ON(page == head); map = kmap_atomic(page) + offset; } if (*map == SWAP_CONT_MAX) { kunmap_atomic(map); - page = list_entry(page->lru.next, struct page, lru); + page = list_next_entry(page, lru); if (page == head) { ret = false; /* add count continuation */ goto out; @@ -3681,12 +3681,10 @@ static bool swap_count_continued(struct swap_info_struct *si, } *map += 1; kunmap_atomic(map); - page = list_entry(page->lru.prev, struct page, lru); - while (page != head) { + while ((page = list_prev_entry(page, lru)) != head) { map = kmap_atomic(page) + offset; *map = COUNT_CONTINUED; kunmap_atomic(map); - page = list_entry(page->lru.prev, struct page, lru); } ret = true; /* incremented */ @@ -3697,7 +3695,7 @@ static bool swap_count_continued(struct swap_info_struct *si, BUG_ON(count != COUNT_CONTINUED); while (*map == COUNT_CONTINUED) { kunmap_atomic(map); - page = list_entry(page->lru.next, struct page, lru); + page = list_next_entry(page, lru); BUG_ON(page == head); map = kmap_atomic(page) + offset; } @@ -3706,13 +3704,11 @@ static bool swap_count_continued(struct swap_info_struct *si, if (*map == 0) count = 0; kunmap_atomic(map); - page = list_entry(page->lru.prev, struct page, lru); - while (page != head) { + while ((page = list_prev_entry(page, lru)) != head) { map = kmap_atomic(page) + offset; *map = SWAP_CONT_MAX | count; count = COUNT_CONTINUED; kunmap_atomic(map); - page = list_entry(page->lru.prev, struct page, lru); } ret = count == COUNT_CONTINUED; }