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=-9.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 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 3B6E4C4363D for ; Wed, 7 Oct 2020 02:50:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A2C7E207EA for ; Wed, 7 Oct 2020 02:49:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A2C7E207EA 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 09815900002; Tue, 6 Oct 2020 22:49:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F3DB86B0062; Tue, 6 Oct 2020 22:49:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DDC87900002; Tue, 6 Oct 2020 22:49:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0035.hostedemail.com [216.40.44.35]) by kanga.kvack.org (Postfix) with ESMTP id A9B296B005C for ; Tue, 6 Oct 2020 22:49:58 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 4AB183628 for ; Wed, 7 Oct 2020 02:49:58 +0000 (UTC) X-FDA: 77343599676.09.birds77_6002c00271cb Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id 2F036180AD804 for ; Wed, 7 Oct 2020 02:49:58 +0000 (UTC) X-HE-Tag: birds77_6002c00271cb X-Filterd-Recvd-Size: 2940 Received: from huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Wed, 7 Oct 2020 02:49:57 +0000 (UTC) Received: from dggeme704-chm.china.huawei.com (unknown [172.30.72.57]) by Forcepoint Email with ESMTP id ECC9AD7A04AD3283F671; Wed, 7 Oct 2020 10:49:53 +0800 (CST) Received: from dggeme753-chm.china.huawei.com (10.3.19.99) by dggeme704-chm.china.huawei.com (10.1.199.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1913.5; Wed, 7 Oct 2020 10:49:53 +0800 Received: from dggeme753-chm.china.huawei.com ([10.7.64.70]) by dggeme753-chm.china.huawei.com ([10.7.64.70]) with mapi id 15.01.1913.007; Wed, 7 Oct 2020 10:49:53 +0800 From: linmiaohe To: "akpm@linux-foundation.org" CC: "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] mm: swap: Use memset to fill the swap_map with SWAP_HAS_CACHE Thread-Topic: [PATCH] mm: swap: Use memset to fill the swap_map with SWAP_HAS_CACHE Thread-Index: AdacVHOfcvqglLF2RVOhF41KsDdb4w== Date: Wed, 7 Oct 2020 02:49:53 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.174.177.16] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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: Friendly ping. > We could use helper memset to fill the swap_map with SWAP_HAS_CACHE inste= ad of a direct loop here to simplify the code. Also we can remove the local= variable i and map this way. > > Signed-off-by: Miaohe Lin > --- > mm/swapfile.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/mm/swapfile.c b/mm/swapfile.c index 8feaab31a3a9..b0b629b24e= 3a 100644 > --- a/mm/swapfile.c > +++ b/mm/swapfile.c > @@ -975,8 +975,7 @@ static int swap_alloc_cluster(struct swap_info_struct= *si, swp_entry_t *slot) { > unsigned long idx; > struct swap_cluster_info *ci; > - unsigned long offset, i; > - unsigned char *map; > + unsigned long offset; > =20 > /* > * Should not even be attempting cluster allocations when huge @@ -996,= 9 +995,7 @@ static int swap_alloc_cluster(struct swap_info_struct *si, swp_= entry_t *slot) > alloc_cluster(si, idx); > cluster_set_count_flag(ci, SWAPFILE_CLUSTER, CLUSTER_FLAG_HUGE); > =20 > - map =3D si->swap_map + offset; > - for (i =3D 0; i < SWAPFILE_CLUSTER; i++) > - map[i] =3D SWAP_HAS_CACHE; > + memset(si->swap_map + offset, SWAP_HAS_CACHE, SWAPFILE_CLUSTER); > unlock_cluster(ci); > swap_range_alloc(si, offset, SWAPFILE_CLUSTER); > *slot =3D swp_entry(si->type, offset); > -- > 2.19.1 >