Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3741190yba; Tue, 23 Apr 2019 08:52:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqyLOJYz7F0Xz6eB3ROzbow+AdVzsd3EAzMi5TY3zMu1u9dDwDoAKBxUFn7T9YZfC3Pg0iLz X-Received: by 2002:a63:1364:: with SMTP id 36mr20571819pgt.436.1556034732122; Tue, 23 Apr 2019 08:52:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556034732; cv=none; d=google.com; s=arc-20160816; b=oXJyNH5YXNy6QwHv49EbxuuTRGzVqV2MC0RG7m+GUst0N79B2nzDTLU3GR2lMbi9XQ x7/z3HW6QrmNaPLUdzs79fDGmoQ2QHXYU9R8e6QLDgNRthVWaqls/CQ14aq4pUDfzqdH +sZLyNS7WiVb6r4o5vJOyCSxpLiix/YwrAn7sVz8fKfK5v7zjif7XejhPPfxZAEPUzSl J5jKjRMl2aVb2K7T+8g/g8lCouH16FdpafZR8JWhDNsrit6B01bWpooNk9z9jCJKmp4d Kr12/PS0rTeW78XcIShcd9XsOKPIEAm90mf/0wAi4AOE8Os2yHdj4/N3TQcdNP5to2Ww 1mPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=NX8ReJ0mEJHTT/4mNI990FYobWB8w77dfM3zQRrUVsI=; b=DHUtu68+tk6KTb8XAl2ORiovRXeLPAMy55E2zzaN3CwXiPqrs3tDU+PgPl+q1JxlYh kt8/0z7e1sABLI3kypRSAreuHzHyJe7Qm+jhPEBy9MP9oBuopjtaK+XEuUJm+aBqwOj7 N8+mlhvfGiJY6rLNu59cgUgGpqRU6/s4Hr9Of3caDajoLC1MoP+ZdhxdlZyowEFDbSnp uLJbU7KweZ39+oiTmynq2u7PptMyY2Vnp1h0Ny57l4G0RGk/52hLNbLCDbRo875R3JL1 MIvH6yNTHst39Cat+5J6x/6lSS1/mhdeVqT1mh/tzlabxwG3quMHmGS68jBDmOaDquM6 nvQQ== 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 u79si16718161pfa.6.2019.04.23.08.51.56; Tue, 23 Apr 2019 08:52:12 -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 S1728459AbfDWPu5 (ORCPT + 99 others); Tue, 23 Apr 2019 11:50:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37920 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727467AbfDWPu5 (ORCPT ); Tue, 23 Apr 2019 11:50:57 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id F421D308792D; Tue, 23 Apr 2019 15:50:56 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2AE6419936; Tue, 23 Apr 2019 15:50:52 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id x3NFopJZ019464; Tue, 23 Apr 2019 11:50:51 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id x3NFopO6019460; Tue, 23 Apr 2019 11:50:51 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Tue, 23 Apr 2019 11:50:51 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Huaisheng Ye cc: snitzer@redhat.com, agk@redhat.com, prarit@redhat.com, chengnt@lenovo.com, dm-devel@redhat.com, linux-kernel@vger.kernel.org, Huaisheng Ye Subject: Re: [PATCH] dm-writecache: add unlikely for returned value of rb_next/prev In-Reply-To: <20190412152814.27158-1-huye@redhat.com> Message-ID: References: <20190412152814.27158-1-huye@redhat.com> User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Tue, 23 Apr 2019 15:50:57 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 12 Apr 2019, Huaisheng Ye wrote: > 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 Acked-by: Mikulas Patocka > --- > 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 >