From patchwork Thu Jul 23 10:46:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 11680595 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 5C4AD13B1 for ; Thu, 23 Jul 2020 10:46:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 28C0E2071A for ; Thu, 23 Jul 2020 10:46:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="jBirwTud" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 28C0E2071A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1F6086B0002; Thu, 23 Jul 2020 06:46:47 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1A62D8D0002; Thu, 23 Jul 2020 06:46:47 -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 096598D0001; Thu, 23 Jul 2020 06:46:47 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0203.hostedemail.com [216.40.44.203]) by kanga.kvack.org (Postfix) with ESMTP id E521C6B0005 for ; Thu, 23 Jul 2020 06:46:46 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id A9E09506E4 for ; Thu, 23 Jul 2020 10:46:46 +0000 (UTC) X-FDA: 77069012412.02.tub92_10131f326f3e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin02.hostedemail.com (Postfix) with ESMTP id 843A510097AB6 for ; Thu, 23 Jul 2020 10:46:46 +0000 (UTC) X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,bhe@redhat.com,,RULES_HIT:30012:30054:30064:30070,0,RBL:205.139.110.120:@redhat.com:.lbl8.mailshell.net-62.18.0.100 66.10.201.10;04yfywz7sf1kxu37mxn9g4courzehycspgwb7fjyzkuydwawy9wm3r8q9jskmh9.zr5if77yiib4ejbzi4sgx4cf6qk7y1mr6bowjk1ydky5uxmi5t53tcx9outfob1.a-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: tub92_10131f326f3e X-Filterd-Recvd-Size: 3629 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Thu, 23 Jul 2020 10:46:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595501205; h=from:from:reply-to:subject:subject: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=OIGRu3pWmIoZ+Nju0ceqixWGAqRIjOJir+KRyyVKDd0=; b=jBirwTuddkudXbutQgB0h9rQnKeEzeioMYAtYrXC2l2WWImWpZP4Acu0ns0TJf1+2apKCJ atZFaZCsEiOW9tf78u+TbR6Y+Cbla3k3M0Jt0Y59frGdV2f1axWzleSpOie2TACM/ymT7S n5gqNgOCnCyGGsk1JN45RI/tMb4AGyY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-444-cAo-hXbjN5qL7KcBsCJy_A-1; Thu, 23 Jul 2020 06:46:43 -0400 X-MC-Unique: cAo-hXbjN5qL7KcBsCJy_A-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 88703189CEF3; Thu, 23 Jul 2020 10:46:42 +0000 (UTC) Received: from localhost (ovpn-13-53.pek2.redhat.com [10.72.13.53]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 32FBC1A8F7; Thu, 23 Jul 2020 10:46:38 +0000 (UTC) Date: Thu, 23 Jul 2020 18:46:36 +0800 From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, mike.kravetz@oracle.com, david@redhat.com, anshuman.khandual@arm.com, akpm@linux-foundation.org Subject: [PATCH v3 2/4] mm/hugetlb.c: Remove the unnecessary non_swap_entry() Message-ID: <20200723104636.GS32539@MiWiFi-R3L-srv> References: <20200723032248.24772-1-bhe@redhat.com> <20200723032248.24772-3-bhe@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200723032248.24772-3-bhe@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Rspamd-Queue-Id: 843A510097AB6 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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: If a swap entry tests positive for either is_[migration|hwpoison]_entry(), then its swap_type() is among SWP_MIGRATION_READ, SWP_MIGRATION_WRITE and SWP_HWPOISON. All these types >= MAX_SWAPFILES, exactly what is asserted with non_swap_entry(). So the checking non_swap_entry() in is_hugetlb_entry_migration() and is_hugetlb_entry_hwpoisoned() is redundant. Let's remove it to optimize code. Signed-off-by: Baoquan He Reviewed-by: Mike Kravetz Reviewed-by: David Hildenbrand Reviewed-by: Anshuman Khandual --- v2->v3: Updated patch log according to Anshuman's comment. mm/hugetlb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 3569e731e66b..c14837854392 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -3748,7 +3748,7 @@ bool is_hugetlb_entry_migration(pte_t pte) if (huge_pte_none(pte) || pte_present(pte)) return false; swp = pte_to_swp_entry(pte); - if (non_swap_entry(swp) && is_migration_entry(swp)) + if (is_migration_entry(swp)) return true; else return false; @@ -3761,7 +3761,7 @@ static bool is_hugetlb_entry_hwpoisoned(pte_t pte) if (huge_pte_none(pte) || pte_present(pte)) return false; swp = pte_to_swp_entry(pte); - if (non_swap_entry(swp) && is_hwpoison_entry(swp)) + if (is_hwpoison_entry(swp)) return true; else return false;