NetBSD Problem Report #53439

From msaitoh@five.execsw.org  Tue Jul 10 09:34:59 2018
Return-Path: <msaitoh@five.execsw.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 7865E7A1A1
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 10 Jul 2018 09:34:59 +0000 (UTC)
Message-Id: <20180710093457.67B4E88612B@five.execsw.org>
Date: Tue, 10 Jul 2018 18:34:57 +0900 (JST)
From: msaitoh@execsw.org
Reply-To: msaitoh@execsw.org
To: gnats-bugs@NetBSD.org
Subject: mbuf allocation count should be changed from u_short to u_long (for netstat and systat)
X-Send-Pr-Version: 3.95

>Number:         53439
>Category:       kern
>Synopsis:       mbuf allocation count should be changed from u_short to u_long (for netstat and systat)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jul 10 09:35:00 +0000 2018
>Originator:     Masanobu SAITOH
>Release:        NetBSD 8.99.21
>Organization:
>Environment:
Any
>Description:
	On a big machine, a lot of mbufs is allocated
	(e.g. ixgbe with many core CPU).

	% netstat -m
	2 mbufs in use:
	        2 mbufs allocated to data
	0 calls to protocol drain routines
	% vmstat -m | grep ^mb
	mbpl         512    74745    0        0  9346     0  9346  9346     2   inf    2

	vmstat says 74745 mbufs are allocated by netstat -m (and systat mbufs)
	says only two mbufs are allocated.

>How-To-Repeat:
	Run netstat on 40 core machine with two ixg.
>Fix:
	struct mbstat {
	        u_long  _m_spare;       /* formerly m_mbufs */
	        u_long  _m_spare1;      /* formerly m_clusters */
	        u_long  _m_spare2;      /* spare field */
	        u_long  _m_spare3;      /* formely m_clfree - free clusters */
	        u_long  m_drops;        /* times failed to find space */
	        u_long  m_wait;         /* times waited for space */
	        u_long  m_drain;        /* times drained protocols for space */
	        u_short m_mtypes[256];  /* type specific mbuf allocations */
	};

	Change m_mtypes from u_short to u_long. COMPAT_80 would be required.
	If m_mtypes was just one entry, it would be OK to add new m_mtypes
	next to the current one and make old entry reserved. It would be not
	good to keep 512 bytes spaces.

	/*
	 * Mbuf sysctl variables.
	 */
	#define MBUF_MSIZE              1       /* int: mbuf base size */
	#define MBUF_MCLBYTES           2       /* int: mbuf cluster size */
	#define MBUF_NMBCLUSTERS        3       /* int: limit on the # of clusters */
	#define MBUF_MBLOWAT            4       /* int: mbuf low water mark */
	#define MBUF_MCLLOWAT           5       /* int: mbuf cluster low water mark */
	#define MBUF_STATS              6       /* struct: mbstat */
	#define MBUF_MOWNERS            7       /* struct: m_owner[] */
	#define MBUF_MAXID              8       /* number of valid MBUF ids */

	So, it would be good to change MBUF_STATS as MBUF_OSTATS and
	make new MBUF_STATS with number 8.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.