From owner-svn-src-stable@freebsd.org Sun May 14 14:21:10 2017 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DAE7BD6C563; Sun, 14 May 2017 14:21:10 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 90F431866; Sun, 14 May 2017 14:21:10 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v4EEL94k064959; Sun, 14 May 2017 14:21:09 GMT (envelope-from marius@FreeBSD.org) Received: (from marius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v4EEL9eW064956; Sun, 14 May 2017 14:21:09 GMT (envelope-from marius@FreeBSD.org) Message-Id: <201705141421.v4EEL9eW064956@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marius set sender to marius@FreeBSD.org using -f From: Marius Strobl Date: Sun, 14 May 2017 14:21:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r318274 - in stable/11/sys: kern sys X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 May 2017 14:21:11 -0000 Author: marius Date: Sun May 14 14:21:09 2017 New Revision: 318274 URL: https://svnweb.freebsd.org/changeset/base/318274 Log: MFC: r317982 - Also outside of the KOBJOPLOOKUP macro - which in turn is used by the code auto-generated for *.m - kobj_lookup_method(9) is useful; for example in back-ends or base class device drivers in order to determine whether a default method has been overridden. Thus, allow for the kobj_method_t pointer argument - used by KOBJOPLOOKUP in order to update the cache entry - of kobj_lookup_method(9), to be NULL. Actually, that pointer is redundant as it's just set to the same kobj_method_t that the kobj_lookup_method(9) function returns in the first place, but probably it serves to reduce the number of instructions generated for KOBJOPLOOKUP. - For the same reason, move updating kobj_lookup_{hits,misses} (if KOBJ_STATS is defined) from kobj_lookup_method(9) to KOBJOPLOOKUP. As a side-effect, this gets rid of the convoluted approach of always incrementing kobj_lookup_hits in KOBJOPLOOKUP and then in case of a cache miss, decrementing it in kobj_lookup_method(9) again. Modified: stable/11/sys/kern/subr_kobj.c stable/11/sys/sys/kobj.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/subr_kobj.c ============================================================================== --- stable/11/sys/kern/subr_kobj.c Sun May 14 14:04:32 2017 (r318273) +++ stable/11/sys/kern/subr_kobj.c Sun May 14 14:21:09 2017 (r318274) @@ -213,19 +213,11 @@ kobj_lookup_method(kobj_class_t cls, { kobj_method_t *ce; -#ifdef KOBJ_STATS - /* - * Correct for the 'hit' assumption in KOBJOPLOOKUP and record - * a 'miss'. - */ - kobj_lookup_hits--; - kobj_lookup_misses++; -#endif - ce = kobj_lookup_method_mi(cls, desc); if (!ce) ce = &desc->deflt; - *cep = ce; + if (cep) + *cep = ce; return ce; } Modified: stable/11/sys/sys/kobj.h ============================================================================== --- stable/11/sys/sys/kobj.h Sun May 14 14:04:32 2017 (r318273) +++ stable/11/sys/sys/kobj.h Sun May 14 14:21:09 2017 (r318274) @@ -226,10 +226,12 @@ extern u_int kobj_lookup_misses; kobj_method_t **_cep = \ &OPS->cache[_desc->id & (KOBJ_CACHE_SIZE-1)]; \ kobj_method_t *_ce = *_cep; \ - kobj_lookup_hits++; /* assume hit */ \ - if (_ce->desc != _desc) \ + if (_ce->desc != _desc) { \ _ce = kobj_lookup_method(OPS->cls, \ _cep, _desc); \ + kobj_lookup_misses++; \ + } else \ + kobj_lookup_hits++; \ _m = _ce->func; \ } while(0) #else