From owner-svn-src-all@freebsd.org Sun May 3 00:03:39 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DC0D62C92C1; Sun, 3 May 2020 00:03:39 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49F5mq5Wssz3Myd; Sun, 3 May 2020 00:03:39 +0000 (UTC) (envelope-from glebius@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B8D4D1EBE; Sun, 3 May 2020 00:03:39 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 04303dMf091017; Sun, 3 May 2020 00:03:39 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 04303dfH091016; Sun, 3 May 2020 00:03:39 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <202005030003.04303dfH091016@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Sun, 3 May 2020 00:03:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r360577 - in head/sys: kern sys X-SVN-Group: head X-SVN-Commit-Author: glebius X-SVN-Commit-Paths: in head/sys: kern sys X-SVN-Commit-Revision: 360577 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 May 2020 00:03:39 -0000 Author: glebius Date: Sun May 3 00:03:39 2020 New Revision: 360577 URL: https://svnweb.freebsd.org/changeset/base/360577 Log: Make MBUF_EXT_PGS_ASSERT_SANITY() a macro, so that it prints file:line. While here, stop using struct mbuf_ext_pgs. Reviewed by: gallatin Differential Revision: https://reviews.freebsd.org/D24598 Modified: head/sys/kern/kern_mbuf.c head/sys/sys/mbuf.h Modified: head/sys/kern/kern_mbuf.c ============================================================================== --- head/sys/kern/kern_mbuf.c Sat May 2 23:58:20 2020 (r360576) +++ head/sys/kern/kern_mbuf.c Sun May 3 00:03:39 2020 (r360577) @@ -1145,40 +1145,6 @@ mb_alloc_ext_pgs(int how, m_ext_free_t ext_free) return (m); } -#ifdef INVARIANT_SUPPORT -void -mb_ext_pgs_check(struct mbuf *m) -{ - struct mbuf_ext_pgs *ext_pgs = &m->m_ext_pgs; - - /* - * NB: This expects a non-empty buffer (npgs > 0 and - * last_pg_len > 0). - */ - KASSERT(ext_pgs->npgs > 0, - ("ext_pgs with no valid pages: %p", ext_pgs)); - KASSERT(ext_pgs->npgs <= nitems(m->m_epg_pa), - ("ext_pgs with too many pages: %p", ext_pgs)); - KASSERT(ext_pgs->nrdy <= ext_pgs->npgs, - ("ext_pgs with too many ready pages: %p", ext_pgs)); - KASSERT(ext_pgs->first_pg_off < PAGE_SIZE, - ("ext_pgs with too large page offset: %p", ext_pgs)); - KASSERT(ext_pgs->last_pg_len > 0, - ("ext_pgs with zero last page length: %p", ext_pgs)); - KASSERT(ext_pgs->last_pg_len <= PAGE_SIZE, - ("ext_pgs with too large last page length: %p", ext_pgs)); - if (ext_pgs->npgs == 1) { - KASSERT(ext_pgs->first_pg_off + ext_pgs->last_pg_len <= - PAGE_SIZE, ("ext_pgs with single page too large: %p", - ext_pgs)); - } - KASSERT(ext_pgs->hdr_len <= sizeof(m->m_epg_hdr), - ("ext_pgs with too large header length: %p", ext_pgs)); - KASSERT(ext_pgs->trail_len <= sizeof(m->m_epg_trail), - ("ext_pgs with too large header length: %p", ext_pgs)); -} -#endif - /* * Clean up after mbufs with M_EXT storage attached to them if the * reference count hits 1. Modified: head/sys/sys/mbuf.h ============================================================================== --- head/sys/sys/mbuf.h Sat May 2 23:58:20 2020 (r360576) +++ head/sys/sys/mbuf.h Sun May 3 00:03:39 2020 (r360577) @@ -401,13 +401,36 @@ m_epg_pagelen(const struct mbuf *m, int pidx, int pgof } } -#ifdef INVARIANT_SUPPORT -void mb_ext_pgs_check(struct mbuf *m); -#endif #ifdef INVARIANTS -#define MBUF_EXT_PGS_ASSERT_SANITY(m) mb_ext_pgs_check((m)) +#define MCHECK(ex, msg) KASSERT((ex), \ + ("Multi page mbuf %p with " #msg " at %s:%d", \ + m, __FILE__, __LINE__)) +/* + * NB: This expects a non-empty buffer (npgs > 0 and + * last_pg_len > 0). + */ +#define MBUF_EXT_PGS_ASSERT_SANITY(m) do { \ + MCHECK(m->m_ext_pgs.npgs > 0, "no valid pages"); \ + MCHECK(m->m_ext_pgs.npgs <= nitems(m->m_epg_pa), \ + "too many pages"); \ + MCHECK(m->m_ext_pgs.nrdy <= m->m_ext_pgs.npgs, \ + "too many ready pages"); \ + MCHECK(m->m_ext_pgs.first_pg_off < PAGE_SIZE, \ + "too large page offset"); \ + MCHECK(m->m_ext_pgs.last_pg_len > 0, "zero last page length"); \ + MCHECK(m->m_ext_pgs.last_pg_len <= PAGE_SIZE, \ + "too large last page length"); \ + if (m->m_ext_pgs.npgs == 1) \ + MCHECK(m->m_ext_pgs.first_pg_off + \ + m->m_ext_pgs.last_pg_len <= PAGE_SIZE, \ + "single page too large"); \ + MCHECK(m->m_ext_pgs.hdr_len <= sizeof(m->m_epg_hdr), \ + "too large header length"); \ + MCHECK(m->m_ext_pgs.trail_len <= sizeof(m->m_epg_trail), \ + "too large header length"); \ +} while (0) #else -#define MBUF_EXT_PGS_ASSERT_SANITY(m) +#define MBUF_EXT_PGS_ASSERT_SANITY(m) do {} while (0); #endif #endif