From nobody Sat Nov 11 19:23:06 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SSQZj1W4Yz50tpF; Sat, 11 Nov 2023 19:23:09 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SSQZj13fhz3Gmq; Sat, 11 Nov 2023 19:23:09 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699730589; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7KrUI+2BnTyiFSb3F7zYbOJgCG59UKLE7VMa782P+B0=; b=iBlX1qgkpjgq1tqvCQvsfZTOknooBsfPITiVhNFxSGrvFhTsKzF9U9jmRAuzeimB2pwxD6 zQukFoQDwsdx1cUMNdH9jiG8pqZy5tP78U+6flHweEJR2bplFY1O4MW3aCm9nP4Ipb+lfa yfrga4ZLquFXDIGywtpEs0BHwmIW7TtatZXpKyWPhLK+ALm5JxrsdgvR7h+FyrnA/ieSZl gs7CWJpOsEdJ91nehzg8C7EJu1+0kV9SXhAdUq4e14QBgVaicv+qOKEmz7io3ERV9cxjWQ UdgE1rAihEQ1ct5l91tqp9UQA3wfdEAAscooFP0VXCNVED51pj5aCHS1s4XT9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699730589; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7KrUI+2BnTyiFSb3F7zYbOJgCG59UKLE7VMa782P+B0=; b=dFXHzRzwzo5AGI2SkzklgnYa3xc6kyVPC0V1q4VZwGV355YR7Tu/1qowlPc/T8RhtVi23a J15iUQSfrTKsNXGzotDBxVfDxSRLPWR0CcrKU/o+b+qXp5dOZoqXecHjZBJxVvak1NmlCK iUWvZMyi9bIXu9tvjiAW0Y0XnM05pjcuDoBzhbJZjcC50A/CQuaph3N5/pydUPDODaUqvn PXX3DP8xD8J48stW9ywwyyZsCrHDmw5JEwMjg1KQJ4AfSrHGF8tztIc+7J2aiokoFYk140 oMQCmMw4VPVXid22njqE1Dr45EB78t04PPytzChhPp3uTVr+iwTUf+ir6q4Qmg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1699730589; a=rsa-sha256; cv=none; b=mpGImnf12EtcGE4ycETZ5SbRcXnNfq2h2cwuSdFFZmiCAAyoWtIlOyulNgGEenwuVEw7PR ef3nxFrQDppqAkVc4piRfrEJ2PbDt4raUIeBXS7FYF4N4zH1O/S130ZysplQYo17gGxsgn fYTG+wQpylueMzfLzE9rW3GROpboHcNctbJuY48YlX2n4TeKPJJV6em1ZWO75lppqgDhAY KdIG6uWQMTxunrhNqSSXZlYFC5oQNlBboQlRyadrqT4RMJfmal3ZIHZpeV/nMTlDyJHg1o uGZEqvrHmUctgxMJg2JTuf/mwww2QMfEA859uWUQmrKGMuJbiIm1uwak68P9Mw== Received: from [IPV6:2601:648:8384:fd00:8dc8:68:d931:e24b] (unknown [IPv6:2601:648:8384:fd00:8dc8:68:d931:e24b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4SSQZh4W3WzkJ5; Sat, 11 Nov 2023 19:23:08 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: Date: Sat, 11 Nov 2023 11:23:06 -0800 List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: git: 7c566d6cfc7b - main - uma: Micro-optimize memory trashing Content-Language: en-US To: Alexander Motin , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202311091821.3A9ILlAJ044944@gitrepo.freebsd.org> From: John Baldwin In-Reply-To: <202311091821.3A9ILlAJ044944@gitrepo.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/9/23 10:21 AM, Alexander Motin wrote: > The branch main has been updated by mav: > > URL: https://cgit.FreeBSD.org/src/commit/?id=7c566d6cfc7bfb913bad89d87386fa21dce8c2e6 > > commit 7c566d6cfc7bfb913bad89d87386fa21dce8c2e6 > Author: Alexander Motin > AuthorDate: 2023-11-09 18:07:46 +0000 > Commit: Alexander Motin > CommitDate: 2023-11-09 18:07:46 +0000 > > uma: Micro-optimize memory trashing > > Use u_long for memory accesses instead of uint32_t. On my tests on > amd64 this by ~30% reduces time spent in those functions thanks to > bigger 64bit accesses. i386 still uses 32bit accesses. > > MFC after: 1 month > --- > sys/vm/uma_dbg.c | 62 ++++++++++++++++++++++++-------------------------------- > 1 file changed, 26 insertions(+), 36 deletions(-) > > diff --git a/sys/vm/uma_dbg.c b/sys/vm/uma_dbg.c > index 36567f3b3968..76dd2bfde2fe 100644 > --- a/sys/vm/uma_dbg.c > +++ b/sys/vm/uma_dbg.c > @@ -64,27 +64,20 @@ static const uint32_t uma_junk = 0xdeadc0de; > int > trash_ctor(void *mem, int size, void *arg, int flags) > { > - int cnt; > - uint32_t *p; > + u_long *p = mem, *e; > > #ifdef DEBUG_MEMGUARD > if (is_memguard_addr(mem)) > return (0); > #endif > > - cnt = size / sizeof(uma_junk); > - > - for (p = mem; cnt > 0; cnt--, p++) > - if (*p != uma_junk) { > -#ifdef INVARIANTS > - panic("Memory modified after free %p(%d) val=%x @ %p\n", > - mem, size, *p, p); > -#else > - printf("Memory modified after free %p(%d) val=%x @ %p\n", > - mem, size, *p, p); > -#endif > - return (0); > - } > + e = p + size / sizeof(*p); > + for (; p < e; p++) { > + if (__predict_true(*p == uma_junk)) > + continue; > + panic("Memory modified after free %p(%d) val=%lx @ %p\n", > + mem, size, *p, p); > + } > return (0); For future reference, switching from printf to panic here for the !INVARIANTS case is a good change I think, but it was probably worth calling out in the commit log (or possibly doing as a separate commit before/after this one). -- John Baldwin