From owner-freebsd-current@freebsd.org Thu Jan 9 11:59:12 2020 Return-Path: Delivered-To: freebsd-current@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 B3C901EB21D for ; Thu, 9 Jan 2020 11:59:12 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mailman.nyi.freebsd.org (mailman.nyi.freebsd.org [IPv6:2610:1c1:1:606c::50:13]) by mx1.freebsd.org (Postfix) with ESMTP id 47tl5X2g2Jz41tx for ; Thu, 9 Jan 2020 11:59:12 +0000 (UTC) (envelope-from hps@selasky.org) Received: by mailman.nyi.freebsd.org (Postfix) id 5B4DD1EB21C; Thu, 9 Jan 2020 11:59:12 +0000 (UTC) Delivered-To: current@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 5B1191EB21B for ; Thu, 9 Jan 2020 11:59:12 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (turbocat.net [IPv6:2a01:4f8:c17:6c4b::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 47tl5W4QR5z41tw; Thu, 9 Jan 2020 11:59:11 +0000 (UTC) (envelope-from hps@selasky.org) Received: from hps2020.home.selasky.org (unknown [62.141.129.235]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 8D35E2600D5; Thu, 9 Jan 2020 12:59:08 +0100 (CET) Subject: Re: M_TEMP trouble in 13.0-CURRENT #0 r355131M From: Hans Petter Selasky To: Poul-Henning Kamp , current@freebsd.org, Jeff Roberson , Konstantin Belousov References: <4164.1578563950@critter.freebsd.dk> <4e52b23e-32ed-6556-a74e-22c809a17fe0@selasky.org> Message-ID: <100f4e72-ef8b-07dc-b1e1-2a3ef4853d31@selasky.org> Date: Thu, 9 Jan 2020 12:58:28 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------3C8BFF9F6C786E18FE56DE12" Content-Language: en-US X-Rspamd-Queue-Id: 47tl5W4QR5z41tw X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of hps@selasky.org designates 2a01:4f8:c17:6c4b::2 as permitted sender) smtp.mailfrom=hps@selasky.org X-Spamd-Result: default: False [-4.94 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; RCPT_COUNT_THREE(0.00)[4]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+a:mail.turbocat.net:c]; FROM_HAS_DN(0.00)[]; HAS_ATTACHMENT(0.00)[]; MIME_GOOD(-0.10)[multipart/mixed,text/plain]; DMARC_NA(0.00)[selasky.org]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; TO_MATCH_ENVRCPT_SOME(0.00)[]; IP_SCORE(-2.64)[ip: (-9.21), ipnet: 2a01:4f8::/29(-2.45), asn: 24940(-1.50), country: DE(-0.02)]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:24940, ipnet:2a01:4f8::/29, country:DE]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Jan 2020 11:59:12 -0000 This is a multi-part message in MIME format. --------------3C8BFF9F6C786E18FE56DE12 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Hi Jeff and Konstantin, You have a logical breakage after the domainset patches for malloc. The size used for allocation statistics is not the same like for freeing causing messed up "vmstat -m". Also you should audit the code for zero-sized allocations, because upon alloc, zero-sized is not counted, while on free it is. See attached patch. --HPS --------------3C8BFF9F6C786E18FE56DE12 Content-Type: text/x-patch; charset=UTF-8; name="domainset.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="domainset.diff" diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index eba9fc3e1ef..aab33873741 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -669,8 +669,10 @@ malloc_domain(size_t size, int *indxp, struct malloc_type *mtp, int domain, krequests[size >> KMEM_ZSHIFT]++; #endif va = uma_zalloc_domain(zone, NULL, domain, flags); - if (va != NULL) + if (__predict_true(va != NULL)) { size = zone->uz_size; + malloc_type_zone_allocated(mtp, size, indx); + } *indxp = indx; return ((void *) va); @@ -699,7 +701,8 @@ malloc_domainset(size_t size, struct malloc_type *mtp, struct domainset *ds, ret = malloc_domain(size, &indx, mtp, domain, flags); } while (ret == NULL && vm_domainset_iter_policy(&di, &domain) == 0); - malloc_type_zone_allocated(mtp, ret == NULL ? 0 : size, indx); + if (__predict_false(ret == NULL)) + malloc_type_zone_allocated(mtp, 0, indx); } else { /* Policy is handled by kmem. */ ret = malloc_large(&size, ds, flags); --------------3C8BFF9F6C786E18FE56DE12--