Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp536399yba; Fri, 12 Apr 2019 08:29:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqxQ23tBI8nKALjWMAXzOb11iwj1Uvze+P6z3O2YMf+nmyKllQXnjudo9ejTQ67fpcgYAu5u X-Received: by 2002:a63:da4e:: with SMTP id l14mr51604422pgj.96.1555082971834; Fri, 12 Apr 2019 08:29:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555082971; cv=none; d=google.com; s=arc-20160816; b=wxOTIIi1FOyQ1VJDiudo6vpAnppOty3rwtkZqdwx7m0ZTMI3lq5H94jtMykpYKX9l4 oEbFqsC46EEtKg4rmr+GGRQH1mBN0AbktqoPFpUQCH5VNMUN308YgHphnEP4LOeKMmMm st/otLLOXuWI713s8KZSu4liWn096Dmo08Zh9LuVaGw3PppZQI56MyykGtcGmkf2Peoo 1bu9vxghLhbwjb8Poh+I4Tvce+wo8ryijMXW9w+jgjP3cCebkMbMqiISKEettUWz+Grq UMHdyHMSn5hQ5jbmzBJ5Nbr4VSjH8iVWw6BfpYqdcHXR081vCsqV2etSTHA8C7UHXo2X gLWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=JPM4a6WUyI0PdhWfsaEBIt1sf2oHDclxrJ/b4VaN7MA=; b=e0RZGsIBVbWCpoJuA/aiSH9bWTsx1ZoYjvuTObd8Ufqo7ooibd4ZSayBThUuaL/sXc Hg1UCNAOH44j3XJgFVmzE5CxArlSKWrujznmWjQKh0I4v4d/hQNI6l3SwhYS1KNO9xJ5 UALSTNEuVECec0DzgxzvmVh47su+M6sk+Gn1bjbQY0knK3HCaB2Wm+8f+PGmv8sbIziX a4/rayeAe+/E+VwVUZ8VuYsfZXIOd2HQPxHyOY1KrDJBgsfqx4LYazpPmZ80/nmzfGei g4xunhyuuTB44eJsTlCxsHf1KOhGmjoxOxlqIT2SJm+tDFeYm14HCV8+e35n9TpEKetp rvdQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ay11si38127828plb.360.2019.04.12.08.29.15; Fri, 12 Apr 2019 08:29:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727197AbfDLP2j (ORCPT + 99 others); Fri, 12 Apr 2019 11:28:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34446 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727170AbfDLP2j (ORCPT ); Fri, 12 Apr 2019 11:28:39 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E5026308CFBF; Fri, 12 Apr 2019 15:28:38 +0000 (UTC) Received: from dhcp16-201-219.khw1.lab.eng.bos.redhat.com (dhcp16-201-219.khw1.lab.eng.bos.redhat.com [10.16.201.219]) by smtp.corp.redhat.com (Postfix) with ESMTP id B252560BEC; Fri, 12 Apr 2019 15:28:31 +0000 (UTC) From: Huaisheng Ye To: mpatocka@redhat.com, snitzer@redhat.com, agk@redhat.com Cc: prarit@redhat.com, chengnt@lenovo.com, dm-devel@redhat.com, linux-kernel@vger.kernel.org, Huaisheng Ye Subject: [PATCH] dm-writecache: add unlikely for returned value of rb_next/prev Date: Fri, 12 Apr 2019 11:28:14 -0400 Message-Id: <20190412152814.27158-1-huye@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Fri, 12 Apr 2019 15:28:38 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Huaisheng Ye In functions writecache_discard and writecache_find_entry, there is high probablity that the pointer of structure rb_node doesn't equal to NULL. Add unlikly for the pointer node. Signed-off-by: Huaisheng Ye --- drivers/md/dm-writecache.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c index 5b4d1c1..cfbbfbc 100644 --- a/drivers/md/dm-writecache.c +++ b/drivers/md/dm-writecache.c @@ -571,7 +571,7 @@ static struct wc_entry *writecache_find_entry(struct dm_writecache *wc, node = rb_prev(&e->rb_node); else node = rb_next(&e->rb_node); - if (!node) + if (unlikely(!node)) return e; e2 = container_of(node, struct wc_entry, rb_node); if (read_original_sector(wc, e2) != block) @@ -804,7 +804,7 @@ static void writecache_discard(struct dm_writecache *wc, sector_t start, sector_ writecache_free_entry(wc, e); } - if (!node) + if (unlikely(!node)) break; e = container_of(node, struct wc_entry, rb_node); -- 1.8.3.1