From owner-svn-src-all@freebsd.org Fri Jul 10 08:37:35 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 DAF9E363CD5; Fri, 10 Jul 2020 08:37:35 +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) 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 4B35yR1Ktpz4Kqb; Fri, 10 Jul 2020 08:37:34 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-wm1-x342.google.com with SMTP id 17so4982177wmo.1; Fri, 10 Jul 2020 01:37:34 -0700 (PDT) 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=XdmVb1jcH6gmU+aFH0vi4PmV0BL6UmkArM8sU1ZYUAE=; b=n+ebrB3U/dl0ArmWHlSxuSpKWJ9QZ/Ars9AIuriYVrrDssM5ZBRWpyswH5FxL4mIya aMfDes4EKNlT/Qmgnpa7XCmN53prBLgiP5LzS4T97Nns6edwG4HKiJ2nHbCEurpc+k4T QhsKJiPH7c2LI13f/gyTSyps7DsHYlt9WLCm+JjNIwxD2BaQnD3ro2jgdZwdC2/luqNO 1L0U8qvRHdjHO/E9AqJGL221utDt91K9O+0j11tZQi9Gslz3jjw20eVGXIy/pX+4bOUG kPf5sVl6pERFhlUzZ6VSwphP4UfhellRB04lJHwE/Xz2UNDGf3UBd2qjAeACPQcRP2G9 w3Hw== 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=XdmVb1jcH6gmU+aFH0vi4PmV0BL6UmkArM8sU1ZYUAE=; b=XtkBsXxb8UnYXTGOw1HUmACwVpnfZ5pE+TphbwjGQY6Uy2uac0aMtsyTbnbINRWx+8 TbGVPgJ++NUfQVYIh13OEvwwc4KBi5cFEqwkA9TA96+8fxXhaDUznrbVkMxdznEBBNqD uKm/2zkRqOpN/+OcBMdDoJxuQbUdvDVKQ7acN3cjN5eQ5ZIjJE8CxZGFz39Ea8+1p7Rq F9T5783c+WUmdRyLopTCLx1ZY1fbDf10levtVmPJLWsVndOEIEW4i+cCe/UDtTVcYh5e zB7yRLt7yc2ymlhTQ35wUE3a/CLAwDyHC9836weWrNo8bQKZTJ38xdUDnyaGuLvoiinH xUXw== X-Gm-Message-State: AOAM533WPTL4QkOh12hgstjw4Qwa4Bdab1vQJf9n/mtOl56iNTiERXjI 5y98DsAZQ+Hp5opXYpIGw31PyF95ZeDTv7uxofywOg== X-Google-Smtp-Source: ABdhPJwdwv37I+WY6Ca6BDDSUGyIx3BFAC/PIas2DmriFUyTBTpeatHuDg5SZudq23YPvETZK6eYOVAyP1AJ/tP+Kj0= X-Received: by 2002:a1c:e90d:: with SMTP id q13mr4163326wmc.187.1594370252787; Fri, 10 Jul 2020 01:37:32 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:adf:9d84:0:0:0:0:0 with HTTP; Fri, 10 Jul 2020 01:37:32 -0700 (PDT) In-Reply-To: References: <202007100646.06A6kgnX015296@repo.freebsd.org> <20200710082549.GC74062@freefall.freebsd.org> From: Mateusz Guzik Date: Fri, 10 Jul 2020 10:37:32 +0200 Message-ID: Subject: Re: svn commit: r363068 - head/sys/kern To: "Piotr P. Stefaniak" Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4B35yR1Ktpz4Kqb X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=n+ebrB3U; 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.76 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.001]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FREEMAIL_FROM(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36]; NEURAL_HAM_LONG(-1.04)[-1.037]; TO_DN_SOME(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::342:from]; NEURAL_HAM_SHORT(-0.73)[-0.726]; 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:dkim] 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, 10 Jul 2020 08:37:35 -0000 On 7/10/20, Mateusz Guzik wrote: > On 7/10/20, Piotr P. Stefaniak wrote: >>> */ >>>- memcpy(sbp, &mp->mnt_stat, sizeof(*sbp)); >>>+ if (sbp != &mp->mnt_stat) >>>+ memcpy(sbp, &mp->mnt_stat, sizeof(*sbp)); >>> >> >> Slightly unrelated question: wouldn't it be prudent to incorporate this >> logic into memcpy? >> > > Calls like that are just abusing the routine and indicate design > problems in the consumer. > Adding the branch into the routine would add overhead for everyone. > > However, now that you mention it, it may be prudent to do something like > this: > > dtrace -n 'fbt::memcpy:entry,fbt::memmove:entry /arg1 == arg2/ { > @[stack()] = count(); }' > > and run your favourite workload. > Oops, that should be: dtrace -n 'fbt::memcpy:entry,fbt::memmove:entry /arg0 == arg1/ { @[stack()] = count(); }' You can look for other abuse too, here are 0-sized calls: dtrace -n 'fbt::memcpy:entry,fbt::memmove:entry,fbt::memset:entry /arg2 == 0/ { @[probefunc,stack()] = count(); }' -- Mateusz Guzik