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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7FFC4C433EF for ; Wed, 18 May 2022 08:56:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F006B6B0074; Wed, 18 May 2022 04:56:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EAFC56B0075; Wed, 18 May 2022 04:56:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D51F86B0082; Wed, 18 May 2022 04:56:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id C40E26B0074 for ; Wed, 18 May 2022 04:56:52 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9FD2A2052F for ; Wed, 18 May 2022 08:56:52 +0000 (UTC) X-FDA: 79478258664.23.97C2371 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf05.hostedemail.com (Postfix) with ESMTP id BEBCD1000D5 for ; Wed, 18 May 2022 08:56:28 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id D7D0021BC3; Wed, 18 May 2022 08:56:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1652864210; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=criOZiMFw6OxUa9n7KuC0jcpPnGIpjQereGBGjQYi1Y=; b=Gf8+7UBNs9qJ1vft7M7F13PU7NMuIk1XlFshtcGo2jCoAZvwClz8KH/EoLer1KASBcMGG+ vKgEQ6r1af6XuFpTU3qqFWSz33Bsbs+2VeyvIjyPFvSTrO82ssmyT18amhstMatldhB8vv 9gTqprIboLSFmYIksLGiUkx6us3ITBo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1652864210; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=criOZiMFw6OxUa9n7KuC0jcpPnGIpjQereGBGjQYi1Y=; b=THrHaklwYq15wL9i34o83RidmGlLFjvReNxdjH9HtU42clbjZOPdAl8lsR9M8x6CLjXjEd bYjBNVdaUzgR1FAQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id F3D8413A6D; Wed, 18 May 2022 08:56:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id GHanONG0hGIwegAAMHmgww (envelope-from ); Wed, 18 May 2022 08:56:49 +0000 Date: Wed, 18 May 2022 10:56:48 +0200 From: Oscar Salvador To: Miaohe Lin Cc: akpm@linux-foundation.org, willy@infradead.org, vbabka@suse.cz, dhowells@redhat.com, neilb@suse.de, apopple@nvidia.com, david@redhat.com, surenb@google.com, peterx@redhat.com, naoya.horiguchi@nec.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 03/15] mm/swap: fold __swap_info_get() into its sole caller Message-ID: References: <20220509131416.17553-1-linmiaohe@huawei.com> <20220509131416.17553-4-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220509131416.17553-4-linmiaohe@huawei.com> X-Rspamd-Queue-Id: BEBCD1000D5 X-Stat-Signature: 4tebqtquyknrezds43bsbb8punj6hq3o Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=Gf8+7UBN; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=THrHaklw; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf05.hostedemail.com: domain of osalvador@suse.de designates 195.135.220.28 as permitted sender) smtp.mailfrom=osalvador@suse.de X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1652864188-778416 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: On Mon, May 09, 2022 at 09:14:04PM +0800, Miaohe Lin wrote: > Fold __swap_info_get() into its sole caller to make code more clear. > Minor readability improvement. > > Signed-off-by: Miaohe Lin Reviewed-by: Oscar Salvador > --- > mm/swapfile.c | 24 ++++++------------------ > 1 file changed, 6 insertions(+), 18 deletions(-) > > diff --git a/mm/swapfile.c b/mm/swapfile.c > index 05ca79e68d63..0aee6286d6a7 100644 > --- a/mm/swapfile.c > +++ b/mm/swapfile.c > @@ -1123,7 +1123,7 @@ int get_swap_pages(int n_goal, swp_entry_t swp_entries[], int entry_size) > return n_ret; > } > > -static struct swap_info_struct *__swap_info_get(swp_entry_t entry) > +static struct swap_info_struct *_swap_info_get(swp_entry_t entry) > { > struct swap_info_struct *p; > unsigned long offset; > @@ -1138,8 +1138,13 @@ static struct swap_info_struct *__swap_info_get(swp_entry_t entry) > offset = swp_offset(entry); > if (offset >= p->max) > goto bad_offset; > + if (data_race(!p->swap_map[swp_offset(entry)])) > + goto bad_free; > return p; > > +bad_free: > + pr_err("%s: %s%08lx\n", __func__, Unused_offset, entry.val); > + goto out; > bad_offset: > pr_err("%s: %s%08lx\n", __func__, Bad_offset, entry.val); > goto out; > @@ -1152,23 +1157,6 @@ static struct swap_info_struct *__swap_info_get(swp_entry_t entry) > return NULL; > } > > -static struct swap_info_struct *_swap_info_get(swp_entry_t entry) > -{ > - struct swap_info_struct *p; > - > - p = __swap_info_get(entry); > - if (!p) > - goto out; > - if (data_race(!p->swap_map[swp_offset(entry)])) > - goto bad_free; > - return p; > - > -bad_free: > - pr_err("%s: %s%08lx\n", __func__, Unused_offset, entry.val); > -out: > - return NULL; > -} > - > static struct swap_info_struct *swap_info_get_cont(swp_entry_t entry, > struct swap_info_struct *q) > { > -- > 2.23.0 > > -- Oscar Salvador SUSE Labs