From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D6161EB5F8 for ; Thu, 29 Jan 2026 23:20:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769728836; cv=none; b=XwaceXOxlSGO5Q/YZmk0bM/+ZFaFiJbvyiB5lzFVrg+9/GKeOFc4NZ875L0LDrnTVL37TiXuCu47u5MSBOYAyG67mMTB3Ahq2vkE4zPxGCVkvhHe+gFG+vt7DalvRiz9mZkgY8wehcnZyp91KdZ4k5JpgvrAmAAbFd4wAXq5j0c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769728836; c=relaxed/simple; bh=vqzujNeThkBr6ZJTdk499bLrywLr5OWcK6PiPvAOV/U=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=fOZtE7CYFVvXWIALyptJ3ZY6fmhqOrJAqn8ogQGAg0vRRliDMasN4FCiodZ90393YaY4tly2RX8Tpw/RvhWKqNSrZ1mA+nGbe32/MYKJ2yw/+xyL5V0oyDhC5dNWwn/CZE1LVyIOw/6YjRQZ6K7kZ0sMwJNstGjju592J2K61oA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=1sz4SE7D; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="1sz4SE7D" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 113CCC4CEF7; Thu, 29 Jan 2026 23:20:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1769728836; bh=vqzujNeThkBr6ZJTdk499bLrywLr5OWcK6PiPvAOV/U=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=1sz4SE7DTAt9hNqHZizKE0enbVM+8uMqs/hkiHuE3H3wfpuf6ADaAK3d+RRw32yCu iSvx7WBSXzkJiNlhDUNi7u1rcLsTA2i7pF3EvagaGCTXY1afcApN75j91sE98j7DJb k6+zZLYGGRh9EywSrERWrfB9geT5I+SOTL82ktl8= Date: Thu, 29 Jan 2026 15:20:35 -0800 From: Andrew Morton To: Matteo Croce Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH] KUnit: memcpy: add benchmark Message-Id: <20260129152035.1fbdddb214c75875b67ba5b9@linux-foundation.org> In-Reply-To: <20260129004328.102770-1-teknoraver@meta.com> References: <20260129004328.102770-1-teknoraver@meta.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 29 Jan 2026 01:43:28 +0100 Matteo Croce wrote: > Add optional benchmarks for memcpy() and memmove() functions. > Each benchmark is run twice: first with buffers aligned and then with > buffers unaligned, to spot unaligned accesses on platforms where they > have a noticeable performance impact. > > ... > > +static int memcpy_bench_align(struct kunit *test, bool unalign) > +{ > + u64 start, end, total_ns = 0; > + char *buf1; > + char *buf2; > + int ret = 0; > + > + buf1 = kzalloc(COPY_SIZE, GFP_KERNEL); > + if (!buf1) > + return -ENOMEM; > + > + buf2 = kzalloc(COPY_SIZE, GFP_KERNEL); > + if (!buf2) { > + ret = -ENOMEM; > + goto out_free; > + } > + > + preempt_disable(); > + for (int i = 0; i < COPIES_NUM; i++) { > + start = ktime_get_ns(); > + memcpy(buf1 + unalign, buf2, COPY_SIZE - unalign); > + end = ktime_get_ns(); > + total_ns += end - start; > + cond_resched(); Is cond_resched() inside preempt_disable() actually legal? Might be, but it doesn't make a lot of sense, does it? > + } > + preempt_enable(); > +