From owner-svn-src-all@FreeBSD.ORG Thu Feb 3 11:52:22 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C47C0106566C; Thu, 3 Feb 2011 11:52:22 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B391F8FC14; Thu, 3 Feb 2011 11:52:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p13BqM0v044437; Thu, 3 Feb 2011 11:52:22 GMT (envelope-from rrs@svn.freebsd.org) Received: (from rrs@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p13BqM8u044432; Thu, 3 Feb 2011 11:52:22 GMT (envelope-from rrs@svn.freebsd.org) Message-Id: <201102031152.p13BqM8u044432@svn.freebsd.org> From: Randall Stewart Date: Thu, 3 Feb 2011 11:52:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r218219 - head/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 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: Thu, 03 Feb 2011 11:52:22 -0000 Author: rrs Date: Thu Feb 3 11:52:22 2011 New Revision: 218219 URL: http://svn.freebsd.org/changeset/base/218219 Log: Fix the per CPU stats so that: 1) They don't use the giant "MAX_CPU" define and instead are allocated dynamically based on mp_ncpus 2) Will zero with the netstat -z -s -p sctp 3) Will be properly handled by both the sctp_init and finish (the multi-net stuff was incorrectly bzero'ing in sctp_init the wrong size.. the bzero is now moved to the right places). And of course the free is put in at the very end. MFC after: 3 Months Modified: head/sys/netinet/sctp_pcb.c head/sys/netinet/sctp_pcb.h head/sys/netinet/sctp_sysctl.c head/sys/netinet/sctp_usrreq.c Modified: head/sys/netinet/sctp_pcb.c ============================================================================== --- head/sys/netinet/sctp_pcb.c Thu Feb 3 11:39:49 2011 (r218218) +++ head/sys/netinet/sctp_pcb.c Thu Feb 3 11:52:22 2011 (r218219) @@ -1,5 +1,8 @@ /*- * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2008-2011, by Randall Stewart, rrs@lakerest.net and + * Michael Tuexen, tuexen@fh-muenster.de + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -5599,11 +5602,18 @@ sctp_pcb_init() #if defined(SCTP_LOCAL_TRACE_BUF) bzero(&SCTP_BASE_SYSCTL(sctp_log), sizeof(struct sctp_log)); #endif +#if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT) + SCTP_MALLOC(SCTP_BASE_STATS, struct sctpstat *, + (mp_ncpus * sizeof(struct sctpstat)), + SCTP_M_MCORE); +#endif (void)SCTP_GETTIME_TIMEVAL(&tv); #if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT) + bzero(SCTP_BASE_STATS, (sizeof(struct sctpstat) * mp_ncpus)); SCTP_BASE_STATS[PCPU_GET(cpuid)].sctps_discontinuitytime.tv_sec = (uint32_t) tv.tv_sec; SCTP_BASE_STATS[PCPU_GET(cpuid)].sctps_discontinuitytime.tv_usec = (uint32_t) tv.tv_usec; #else + bzero(&SCTP_BASE_STATS, sizeof(struct sctpstat)); SCTP_BASE_STAT(sctps_discontinuitytime).tv_sec = (uint32_t) tv.tv_sec; SCTP_BASE_STAT(sctps_discontinuitytime).tv_usec = (uint32_t) tv.tv_usec; #endif @@ -5846,7 +5856,9 @@ sctp_pcb_finish(void) SCTP_HASH_FREE(SCTP_BASE_INFO(sctp_ephash), SCTP_BASE_INFO(hashmark)); if (SCTP_BASE_INFO(sctp_tcpephash) != NULL) SCTP_HASH_FREE(SCTP_BASE_INFO(sctp_tcpephash), SCTP_BASE_INFO(hashtcpmark)); - +#if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT) + SCTP_FREE(SCTP_BASE_STATS, SCTP_M_MCORE); +#endif } Modified: head/sys/netinet/sctp_pcb.h ============================================================================== --- head/sys/netinet/sctp_pcb.h Thu Feb 3 11:39:49 2011 (r218218) +++ head/sys/netinet/sctp_pcb.h Thu Feb 3 11:52:22 2011 (r218219) @@ -1,6 +1,8 @@ /*- * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. - * + * Copyright (c) 2008-2011, by Randall Stewart, rrs@lakerest.net and + * Michael Tuexen, tuexen@fh-muenster.de + * All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * @@ -240,7 +242,7 @@ struct sctp_base_info { */ struct sctp_epinfo sctppcbinfo; #if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT) - struct sctpstat sctpstat[MAXCPU]; + struct sctpstat *sctpstat; #else struct sctpstat sctpstat; #endif Modified: head/sys/netinet/sctp_sysctl.c ============================================================================== --- head/sys/netinet/sctp_sysctl.c Thu Feb 3 11:39:49 2011 (r218218) +++ head/sys/netinet/sctp_sysctl.c Thu Feb 3 11:52:22 2011 (r218219) @@ -1,5 +1,8 @@ /*- * Copyright (c) 2007, by Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2008-2011, by Randall Stewart, rrs@lakerest.net and + * Michael Tuexen, tuexen@fh-muenster.de + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -648,8 +651,18 @@ static int sysctl_stat_get(SYSCTL_HANDLER_ARGS) { int cpu, error; - struct sctpstat sb, *sarry; + struct sctpstat sb, *sarry, *cpin = NULL; + if ((req->newptr) && (req->newlen == sizeof(struct sctpstat))) { + /* + * User wants us to clear or at least reset the counters to + * the specified values. + */ + cpin = (struct sctpstat *)req->newptr; + } else if (req->newptr) { + /* Must be a stat structure */ + return (EINVAL); + } memset(&sb, 0, sizeof(sb)); for (cpu = 0; cpu < mp_ncpus; cpu++) { sarry = &SCTP_BASE_STATS[cpu]; @@ -789,6 +802,9 @@ sysctl_stat_get(SYSCTL_HANDLER_ARGS) sb.sctps_send_burst_avoid += sarry->sctps_send_burst_avoid; sb.sctps_send_cwnd_avoid += sarry->sctps_send_cwnd_avoid; sb.sctps_fwdtsn_map_over += sarry->sctps_fwdtsn_map_over; + if (cpin) { + memcpy(sarry, cpin, sizeof(struct sctpstat)); + } } error = SYSCTL_OUT(req, &sb, sizeof(sb)); return (error); @@ -1099,7 +1115,7 @@ SYSCTL_PROC(_net_inet_sctp, OID_AUTO, ou #endif #if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT) SYSCTL_PROC(_net_inet_sctp, OID_AUTO, stats, - CTLTYPE_STRUCT | CTLFLAG_RD, + CTLTYPE_STRUCT | CTLFLAG_RW, 0, 0, sysctl_stat_get, "S,sctpstat", "SCTP statistics (struct sctp_stat)"); #else Modified: head/sys/netinet/sctp_usrreq.c ============================================================================== --- head/sys/netinet/sctp_usrreq.c Thu Feb 3 11:39:49 2011 (r218218) +++ head/sys/netinet/sctp_usrreq.c Thu Feb 3 11:52:22 2011 (r218219) @@ -1,5 +1,8 @@ /*- * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2008-2011, by Randall Stewart, rrs@lakerest.net and + * Michael Tuexen, tuexen@fh-muenster.de + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -60,8 +63,6 @@ sctp_init(void) { u_long sb_max_adj; - bzero(&SCTP_BASE_STATS, sizeof(struct sctpstat)); - /* Initialize and modify the sysctled variables */ sctp_init_sysctls(); if ((nmbclusters / 8) > SCTP_ASOC_MAX_CHUNKS_ON_QUEUE)