Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 3 May 2020 00:03:39 +0000 (UTC)
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r360577 - in head/sys: kern sys
Message-ID:  <202005030003.04303dfH091016@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202005030003.04303dfH091016>