From owner-svn-src-all@freebsd.org Fri Oct 23 16:11:52 2020 Return-Path: Delivered-To: svn-src-all@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 EDB87449DA5 for ; Fri, 23 Oct 2020 16:11:52 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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-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 4CHq475VH0z4JXv for ; Fri, 23 Oct 2020 16:11:51 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: by mail-wm1-f45.google.com with SMTP id k18so2272875wmj.5 for ; Fri, 23 Oct 2020 09:11:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=uB9o/6Oq8nwdZI/zKgtxz9enWKa50DwsmI7p7LF1tTM=; b=az/IWvyn/pR0nsGi8LCdrwdkXYYY8NSwa2NG/E19dIn9X/5HI5EI1cEuswqPeTRRYp jllP+qqKL6DuUp86H668rUB0DZLPPgwkh5XsazbDmkR3EKZbf4bDyFHaYsWZZmRe+Ym9 K9S8d1b8Y1nGgPT19cG5aZynyYYM6RULyyTFPw8qbreiLdlOq55axs0T1VJlmxLSu1Ui gYVrN3jfUFkuNbOqExcqhQHwEZbQtEHXoJfrmdC5+/+kTZbhr+vhZXXaYZ+HCjajL4gA gxYlC65OAqv95u9jX1JgUEUON0Rn7VcUy/lKEKi9Z27PjSwyZxnFMLnKIuCj8HHjaDSM QUjg== X-Gm-Message-State: AOAM533eo+cUcpTLNcngt+ty7qpb0ZqBliIkpmIKF4ra/5u7QsPBG1f4 xYj6hCkyzHEAQ84WpGTmaO/wCw== X-Google-Smtp-Source: ABdhPJxXtP0Xq6t+sLI58e9fSNPmECW9lRrd0wWpA+Gap4njExPLQH+PM/TiqoqC5yddQNGf0yE71A== X-Received: by 2002:a1c:7c1a:: with SMTP id x26mr3105822wmc.4.1603469509992; Fri, 23 Oct 2020 09:11:49 -0700 (PDT) Received: from [192.168.149.251] (trinity-students-nat.trin.cam.ac.uk. [131.111.193.104]) by smtp.gmail.com with ESMTPSA id r128sm4389116wma.20.2020.10.23.09.11.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Oct 2020 09:11:49 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: svn commit: r366976 - head/sys/kern From: Jessica Clarke In-Reply-To: <202010231556.09NFuMFb079616@repo.freebsd.org> Date: Fri, 23 Oct 2020 17:11:47 +0100 Cc: src-committers , svn-src-all , svn-src-head@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <202010231556.09NFuMFb079616@repo.freebsd.org> To: Mateusz Guzik X-Mailer: Apple Mail (2.3608.120.23.2.1) X-Rspamd-Queue-Id: 4CHq475VH0z4JXv X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of jrtc27@jrtc27.com designates 209.85.128.45 as permitted sender) smtp.mailfrom=jrtc27@jrtc27.com X-Spamd-Result: default: False [-2.14 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17:c]; MV_CASE(0.50)[]; RCVD_COUNT_THREE(0.00)[3]; NEURAL_HAM_SHORT(-0.67)[-0.668]; FORGED_SENDER(0.30)[jrtc27@freebsd.org,jrtc27@jrtc27.com]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; MID_RHS_MATCH_FROM(0.00)[]; FROM_NEQ_ENVFROM(0.00)[jrtc27@freebsd.org,jrtc27@jrtc27.com]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.004]; FREEFALL_USER(0.00)[jrtc27]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; NEURAL_HAM_LONG(-0.97)[-0.967]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[svn-src-all@freebsd.org]; DMARC_NA(0.00)[freebsd.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[209.85.128.45:from]; RWL_MAILSPIKE_POSSIBLE(0.00)[209.85.128.45:from]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[svn-src-all] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 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: Fri, 23 Oct 2020 16:11:53 -0000 On 23 Oct 2020, at 16:56, Mateusz Guzik wrote: >=20 > Author: mjg > Date: Fri Oct 23 15:56:22 2020 > New Revision: 366976 > URL: https://svnweb.freebsd.org/changeset/base/366976 >=20 > Log: > cache: reduce memory waste in struct namecache >=20 > The previous scheme for calculating the total size was doing sizeof > on the struct and then adding the wanted space for the buffer. >=20 > nc_name is at offset 58 while sizeof(struct namecache) is 64. > With CACHE_PATH_CUTOFF of 39 bytes and 1 byte of padding we were > allocating 104 bytes for the entry and never accounting for the 6 > byte padding, wasting that space. >=20 > Modified: > head/sys/kern/vfs_cache.c >=20 > Modified: head/sys/kern/vfs_cache.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/sys/kern/vfs_cache.c Fri Oct 23 15:50:49 2020 = (r366975) > +++ head/sys/kern/vfs_cache.c Fri Oct 23 15:56:22 2020 = (r366976) > @@ -162,6 +162,7 @@ struct namecache_ts { > struct timespec nc_time; /* timespec provided by fs */ > struct timespec nc_dotdottime; /* dotdot timespec provided by = fs */ > int nc_ticks; /* ticks value when entry was = added */ > + int nc_pad; > struct namecache nc_nc; > }; >=20 > @@ -172,12 +173,19 @@ struct namecache_ts { > * alignment for everyone. Note this is a nop for 64-bit platforms. > */ > #define CACHE_ZONE_ALIGNMENT UMA_ALIGNOF(time_t) > -#define CACHE_PATH_CUTOFF 39 >=20 > -#define CACHE_ZONE_SMALL_SIZE (sizeof(struct = namecache) + CACHE_PATH_CUTOFF + 1) > -#define CACHE_ZONE_SMALL_TS_SIZE (sizeof(struct namecache_ts) + = CACHE_PATH_CUTOFF + 1) > -#define CACHE_ZONE_LARGE_SIZE (sizeof(struct = namecache) + NAME_MAX + 1) > -#define CACHE_ZONE_LARGE_TS_SIZE (sizeof(struct namecache_ts) + = NAME_MAX + 1) > +#ifdef __LP64__ > +#define CACHE_PATH_CUTOFF 45 > +#define CACHE_LARGE_PAD 6 > +#else > +#define CACHE_PATH_CUTOFF 41 > +#define CACHE_LARGE_PAD 2 > +#endif Is there any explanation of where these magic constants come from? There should at least be a comment IMO, of better yet have a C expression to evaluate them without needing #ifdef-based hard-coding (which then annoys things like CHERI that has 128-bit pointers in its pure capability kernel that causes us to have to go and reverse-engineer where these numbers came from so we can figure out what the right value should be for us). Jess