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 B33EFC4363D for ; Wed, 7 Oct 2020 02:49:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7262420789 for ; Wed, 7 Oct 2020 02:49:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727033AbgJGCt4 convert rfc822-to-8bit (ORCPT ); Tue, 6 Oct 2020 22:49:56 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:3972 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726627AbgJGCt4 (ORCPT ); Tue, 6 Oct 2020 22:49:56 -0400 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: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Friendly ping. > We could use helper memset to fill the swap_map with SWAP_HAS_CACHE instead 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..b0b629b24e3a 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; > > /* > * 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); > > - map = si->swap_map + offset; > - for (i = 0; i < SWAPFILE_CLUSTER; i++) > - map[i] = SWAP_HAS_CACHE; > + memset(si->swap_map + offset, SWAP_HAS_CACHE, SWAPFILE_CLUSTER); > unlock_cluster(ci); > swap_range_alloc(si, offset, SWAPFILE_CLUSTER); > *slot = swp_entry(si->type, offset); > -- > 2.19.1 >