From owner-freebsd-current@freebsd.org Thu Jan 9 15:17:00 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 AB6791F0C9E for ; Thu, 9 Jan 2020 15:17:00 +0000 (UTC) (envelope-from markjdb@gmail.com) 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 47tqTm3BQ2z4Gd8 for ; Thu, 9 Jan 2020 15:17:00 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mailman.nyi.freebsd.org (Postfix) id 6D6141F0C9D; Thu, 9 Jan 2020 15:17:00 +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 6D24A1F0C9C for ; Thu, 9 Jan 2020 15:17:00 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47tqTl59DBz4Gd7; Thu, 9 Jan 2020 15:16:59 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-qv1-xf2d.google.com with SMTP id x1so3080560qvr.8; Thu, 09 Jan 2020 07:16:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=fxp0ZoST0eXTOPw5oQXzpbb5t/M9PWiiBneBw2qr3b8=; b=bzZbJyUgSsWCt33Tgri+viV+TuKY2utXoh1Yd/0pjO5ZAYXCidiUqDS0zQLa/oeBpj JpRbkYBVbcxQUjCqrMOIPH34bLgb4DiHx6Pw3efqW4iBu6E1439zZ7y6qGLA1m2Ma4Nn VP8/IFjoaxMwK0DY0bDNpPhsGMMqR/BVa7WAecyDynFuveHgnnUYg0ERqgctpGiNRLKX x7vUygvZZHVfosKtzTgKCW5IqjFMvNn+jrE/+8slCau/pBMjJBd8rX2Y3Cm9dbw0coZY AFoYSdoxL5jm3/bBtacdsWlfYMFNvtSW3uOK3LyPggN6utkj7cc3M0fCfJKJRy0jEt10 tLDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=fxp0ZoST0eXTOPw5oQXzpbb5t/M9PWiiBneBw2qr3b8=; b=VXqvtwfp59lcqRMQxMzbRzHlS6HLo4HIV4Ex0TncZqGoxnR54McvRr0pfTwcMoszD/ Lpk4hraHBGPpKJmI+z88gbgCZdxwajhoHWy/ECChbMRM5fgKxm5jHqTjvbq9E3My4L3N 6xQbL3dtE/CNxGEFXNNOdt6xnDYriDG7yb3s+V0AmCrtuO/sD2Ivs0Gr7FGj66ERpG/S Mry7R4I4DeGbahi3LdBR7CASRXvIUoQof/ZHQcJH8TSgxjk8LZ1ciklr54vioG0ef3O7 H8c86Q+a1RuopCgdGYxMdK4HkTk+b9ahCXsHBFYYdHxRtJ+G2rvinGhkdlghDn40XtuR PwGw== X-Gm-Message-State: APjAAAVZ+wPdrJyqlwpA2TprHLLeDJkAGqnCGkgiWbj2T6NLNX5RVeq1 s2BDE+Wpu1KTsUdKbY4WVar6+ivn X-Google-Smtp-Source: APXvYqyLBXV1eMbz8gE7b8A3QwwXHqxw9NqvpBr4na9WEC7W/x3Zoh9eYchNQ94Y/WufZyDMcejV/g== X-Received: by 2002:a0c:bf0b:: with SMTP id m11mr9346883qvi.63.1578583013437; Thu, 09 Jan 2020 07:16:53 -0800 (PST) Received: from raichu (toroon0560w-lp130-05-69-158-183-252.dsl.bell.ca. [69.158.183.252]) by smtp.gmail.com with ESMTPSA id m20sm3157741qkk.15.2020.01.09.07.16.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 07:16:52 -0800 (PST) Sender: Mark Johnston Date: Thu, 9 Jan 2020 10:16:48 -0500 From: Mark Johnston To: Hans Petter Selasky Cc: Poul-Henning Kamp , current@freebsd.org, Jeff Roberson , Konstantin Belousov Subject: Re: M_TEMP trouble in 13.0-CURRENT #0 r355131M Message-ID: <20200109151648.GA1953@raichu> References: <4164.1578563950@critter.freebsd.dk> <4e52b23e-32ed-6556-a74e-22c809a17fe0@selasky.org> <100f4e72-ef8b-07dc-b1e1-2a3ef4853d31@selasky.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <100f4e72-ef8b-07dc-b1e1-2a3ef4853d31@selasky.org> X-Rspamd-Queue-Id: 47tqTl59DBz4Gd7 X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=bzZbJyUg; dmarc=none; spf=pass (mx1.freebsd.org: domain of markjdb@gmail.com designates 2607:f8b0:4864:20::f2d as permitted sender) smtp.mailfrom=markjdb@gmail.com X-Spamd-Result: default: False [-3.35 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36:c]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; DMARC_NA(0.00)[freebsd.org]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; IP_SCORE(-1.65)[ip: (-4.22), ipnet: 2607:f8b0::/32(-2.12), asn: 15169(-1.85), country: US(-0.05)]; FORGED_SENDER(0.30)[markj@freebsd.org,markjdb@gmail.com]; MID_RHS_NOT_FQDN(0.50)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[markj@freebsd.org,markjdb@gmail.com]; RCVD_TLS_ALL(0.00)[] 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 15:17:00 -0000 On Thu, Jan 09, 2020 at 12:58:28PM +0100, Hans Petter Selasky wrote: > 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". Sorry, I committed a different patch in r356555 before seeing this. > Also you should audit the code for zero-sized allocations, because upon > alloc, zero-sized is not counted, while on free it is. Can you explain further? A zero-sized allocation should be rounded up to 16 bytes in all paths. > See attached patch. > > --HPS > 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); > _______________________________________________ > freebsd-current@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"