From owner-svn-src-head@freebsd.org Sun Jan 19 19:51:43 2020 Return-Path: Delivered-To: svn-src-head@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 950A7223171; Sun, 19 Jan 2020 19:51:43 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) (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 4815662lPTz4cdW; Sun, 19 Jan 2020 19:51:42 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-wm1-x342.google.com with SMTP id f129so12615408wmf.2; Sun, 19 Jan 2020 11:51:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Uf0PsYM1gG7hxQbLYvxG6s7tzPG7npmvWLEfiysZNkU=; b=aMbNj/6xdAHQBffBkYmRJYjltTzLycHbQqPTiMjD1tDNoDV6+HXZZGqzXXRiiQ+BQg Wj2gBMKyXmlCZlWHPw/NQN4HHEmjVM9oj4HbI/9Nhe8zAdPsGPSu2CWHcFUSo+7rdxdD lRCooBKj4t/gMuNMHbYP5VRFEDKYlVrAE9qoPbOKFFUm+SoXXnKpWBQyMYuQe1fLBpp9 XRvG49fnJ7Q7YO1/f29wvTfPw1oilM20gDSg0kU7XyQu9ZmiAdShkVirAe4+25zipdnT ajYNcj6iLzc23noopxPAEPy1pApmInVpOjrreaJml19y32E78pbyx+WB2Nv8BuWyEGKr ZINQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Uf0PsYM1gG7hxQbLYvxG6s7tzPG7npmvWLEfiysZNkU=; b=sG5BlHRnvceCueRiyuV0uhfYyS6VIw2jOINeTHcAqpiFdcK/2xxw1bwDi99Ak5ERGL RGl8Lkgf9m2LLcVSA8Mz9XEgxu047ThFpcj1o9DaJfmumBqrGtic0bQQzT6VFng07WUv W8klq90QBpwMjva51wEpSKJy2oPOftvGHDVX9+ZOVk8CCLmd0tuw88Mk0wneIoseLvOg NHvFGY8ZdYgYagl11FTcO8AwZ+WYtaghUvnxqr6L+laHmMxElYLUyv1a6JFKKUjpkdan xrYh0zs3GlsM88r1B+5Qp+WiIk+d75L0IOmqZ2jC+Z0AByW4zd+NpJQj2hACOW8fSTLU vRZg== X-Gm-Message-State: APjAAAWwiQbj86S04SZAF3vePsLXJQ1kH+4OZMJBWOhYBA1jIP8OwD8m zV7HFgzBmP1LNfRKKqNZQ5PGcS1wX+ALoN6Gc80= X-Google-Smtp-Source: APXvYqzmdULNSVBDFLSj7lwJ3jbJutyMsKQof6ovezrAdItLP3JCkliGYPS99Fp5T17Fp0ujWfDxCt/eS/6jVs65zZk= X-Received: by 2002:a05:600c:295a:: with SMTP id n26mr15613679wmd.187.1579463500435; Sun, 19 Jan 2020 11:51:40 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a5d:6b02:0:0:0:0:0 with HTTP; Sun, 19 Jan 2020 11:51:39 -0800 (PST) In-Reply-To: References: <202001191705.00JH5QRQ006755@repo.freebsd.org> From: Mateusz Guzik Date: Sun, 19 Jan 2020 20:51:39 +0100 Message-ID: Subject: Re: svn commit: r356883 - head/sys/kern To: Warner Losh Cc: src-committers , svn-src-all , svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4815662lPTz4cdW X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=aMbNj/6x; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of mjguzik@gmail.com designates 2a00:1450:4864:20::342 as permitted sender) smtp.mailfrom=mjguzik@gmail.com X-Spamd-Result: default: False [-3.00 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36]; FREEMAIL_FROM(0.00)[gmail.com]; MIME_GOOD(-0.10)[text/plain]; IP_SCORE(0.00)[ip: (2.47), ipnet: 2a00:1450::/32(-2.59), asn: 15169(-1.82), country: US(-0.05)]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; TO_DN_SOME(0.00)[]; IP_SCORE_FREEMAIL(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; RCVD_IN_DNSWL_NONE(0.00)[2.4.3.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.5.4.1.0.0.a.2.list.dnswl.org : 127.0.5.0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com.dwl.dnswl.org : 127.0.5.0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Jan 2020 19:51:43 -0000 On 1/19/20, Warner Losh wrote: > On Sun, Jan 19, 2020, 10:05 AM Mateusz Guzik wrote: > >> Author: mjg >> Date: Sun Jan 19 17:05:26 2020 >> New Revision: 356883 >> URL: https://svnweb.freebsd.org/changeset/base/356883 >> >> Log: >> cache: counter_u64_add_protected -> counter_u64_add >> >> Fixes booting on RISC-V where it does happen to not be equivalent. >> > > Any reason we can't just have a counter64 API that works the same both > places rather than hiding what looks to my eye to be just that behind > ifdefs in vfs_cache.c? > Both as in 32 and 64-bit? Note the ifdef is there partially because the counter is not strictly 64-bit but long, meaning 32 bit on i386 and the like. Should someone want to spend time implementing a 32-bit per-cpu counter, they should start with implementing a new facility for counters which are known to always be there (which is vast majority). They can be stored in per-cpu area. Then the common case of just modifying the counter can compile to something fast. For example on amd64 this can be one instruction which uses %gs and an offset known at compilation time. In contrast counter(9) code explicitly allocates memory, meaning all consumers have to deference a pointer. On top of that there is extra computation to find the right address. This bit could be moved elsewhere so that the stored address already has it in, but the fundamental differnce remains. This plus maintaining coherent 64-bit counters requires extra provisions on 32-bit architectures, which could also be avoided for numcachehv. -- Mateusz Guzik