Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp556244rdh; Wed, 14 Feb 2024 05:12:47 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXEraL5HeHmmu/oyEz2CGZBrxmE/v65jOzEk40UKHGHhz6J8fDy0HpVE0RmdH4q3uIHMUv1xM+E8gg1w2a3kbMwNem+djE4rT68MI3ufw== X-Google-Smtp-Source: AGHT+IHKwh1h6ev267HTIvmCH37HKRFJV81S4nmiQzxGL9sE6ftsRQ7Tv2HycQM/CPq/EwmKS09J X-Received: by 2002:a05:6a00:1acb:b0:6e0:527f:fe6e with SMTP id f11-20020a056a001acb00b006e0527ffe6emr2591960pfv.0.1707916366837; Wed, 14 Feb 2024 05:12:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707916366; cv=pass; d=google.com; s=arc-20160816; b=lqOW1paxI0cZy0IBV2iV7cKdyjEDB7p3ehjfM5FwbfnAZanrwqfOnsRGS76K0eqbXl aqiwGymdeBsWVZgrzPfYJxlGxYMOpAzPOXr64SJt++w3dKFPvL7IOKHxwFE/hvIHmAAg Ykq87i1+TGx0U7p8tAc0ta+Q4ZCBLASovLek70HlMY7U4G9tzlQ1ygRDGTFH7Dh6MGdb l+D1SXiR6T55beoMls13tN5hEQKSZBoo3kMVrBS0RJ6JbAm/RdSySjAN7IyG4+sITKgF o3tKOfD4QeticVbXPv3wtBdRbww/Ayg+EVn1ygLE75IKp2eU+d0R5d3cnr97OA3WMAh8 jpRQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=4nzZce/GEXlHrGVLwwLi35yncyVeHeTBvhdjAodvFVg=; fh=UhH+XY/vhYoVCVLFqejgKIwc7/VVAZi3T9/LcysFbCk=; b=dy8epqR9SxF9t2mmZ7vr1RbEsPjluvcX6eaGiYutYzR7U0buk8fsMmx6f7XXgd/IBb wKhjYWnEa9W/7HNlAtEjVyu+A6icdhJnzOQyr0uxUxJWqHAljfLSsGKJNHRCyY7hA4Lf y/t9Jxyod50oqUDlew1dqeKNjzWVIgArx//Ju+SMfNFBXBTapzkjdKJkkkN7WPyVMeSx o0aVTPk+3/IE9wqR3RzElJDrIPisNFFuvWxmryPu8QJHTpjZCaEyxVvw86BC4NmfC7ro fGWkjN7bHeXCtwkSxT6WkJi6C9qFkqVZS6YD34ZXIZC00G6nZPwbJ4sDZ8a4lLHJfIin ZvEQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Pzpkcr3I; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-65238-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65238-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=2; AJvYcCXPvjGOiayfhpLtadfYBQt0f3wt4KmtL3PaqsE/8y1i0lHI36HHrRXaS/QplCeeTNKrLVvXcer3HVA6/jrmQeEaQcrzaZjYYDJ14bNZcg== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id y20-20020a056a00181400b006e02a7721aasi8600365pfa.53.2024.02.14.05.12.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 05:12:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65238-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Pzpkcr3I; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-65238-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65238-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 9A151B2241C for ; Wed, 14 Feb 2024 12:59:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B911352F95; Wed, 14 Feb 2024 12:59:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Pzpkcr3I" Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F400B3FB06 for ; Wed, 14 Feb 2024 12:59:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707915577; cv=none; b=BwakOvnbjhggvR8Y2DPNCkAYnmKgMw7ps4x2Y1QaDp4NO+A7Z0RTrbR1YVIUa4iAJZoO5rgmy2pH4SutNSLdrx62ouxntI2U7s22Ta5NVMQx7vkSL24L3MvAXOKHVuctAwWZNzA7PTNTO5qp0vNMfcKD0bNa5BEk+SBHO6up64U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707915577; c=relaxed/simple; bh=61lA6H3YHOGwam7RJiFhOY4LEq8Z2pxNREg2/X8wxOk=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=omX7ufWs+aXgeD6qdlJQZVPn9Wp7aG2Aa4717NB+PdpPXG3tUZa2NKhhoyE/zeCMZuJiMg+0MObl1RsaDbJUbr2CiqWTx418z36d6sMxjD5J2DFi1I5fJ0Rci0w0XjE8AfTVzjWS23PHcUUs2uDv4kg8ZDyF62eMQfo/3gKfH+I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Pzpkcr3I; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-411ef179d2eso3419185e9.2 for ; Wed, 14 Feb 2024 04:59:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707915574; x=1708520374; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=4nzZce/GEXlHrGVLwwLi35yncyVeHeTBvhdjAodvFVg=; b=Pzpkcr3IN37kTMKrEPUlHm20YX8ADyLOeTpKMrLlZ0z/m2xwMCmw3eAHOb8byVPncP Z8wAkQJy8jzUJtE4RL9pOPE9fFU35DD78ej2fnG3aNl/ygS6NTBmC7XLRcRYR0ubTH4i RQJafPWufPlRazFLhz1f5spn4uO5OD50FwEMWpRcGpX/jGLm8lIXFFsnOH2fL0icosm3 zDnTTBDARVC+Y0CXHrv1ae8qqprxK0pTtng7ZDX9MFX6uS7PTC9/b905jwChou6E9Gvz 4M+2HSTLwEuPTomjjziHrSEzEZ0ZBahZunv2c1WnaaKC1+QmuwPYXKSXu+B96b9f1V9q Ub+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707915574; x=1708520374; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4nzZce/GEXlHrGVLwwLi35yncyVeHeTBvhdjAodvFVg=; b=s0r/Qrzn6SJal4hvrQzTAits3HfVn+G4QYW2JWAv2pp0x5zgTu32BN7dNlQneqasWM 39RvkjQXJ6GKizruGjH9J9ywIODM0peQesweOhvqvqiPu1x47fLKCpYUjw7dth1/Y/a5 q9NhaWs8/6NAMs36KC8r5BfUpP6B/K4lmrqXWNmJT2SZ2jp/zMK72GbKN1nErbDgpSeg TxOEKSSiPKCD8I6tMeTBNzhnHAqO5iu8TfpgmCoUgeUVbu27PoIgX+9bkMg8R8nAFTi/ +Rmt7u3Md9qCRltxD57FckiKrltfpoP2GuW/jEyT3GX8MbHXXTX7FLXaw54wwu9z5EwV 7naw== X-Forwarded-Encrypted: i=1; AJvYcCX0b5LWNbW5fMUlpHlQJi7q+gymXTfTZPnfF1l6EMJFLju8pMeIkIB9k50NaauUkogyejMajmOpWzdmV5vu8/gKUwuKNhArdsk7qAML X-Gm-Message-State: AOJu0Yw6NeUSEpYJ9kGM3Pv4Ycom1m2/gODU/S2jUdKPanu3trPh79QQ NGk7rKw749ENE7nrw4SiSQk+ntMPLN4iADtdQGEhjFz6OFjGwso7jkQFH1Tjdmo= X-Received: by 2002:a05:600c:1386:b0:410:84b9:b9fc with SMTP id u6-20020a05600c138600b0041084b9b9fcmr1858467wmf.15.1707915574177; Wed, 14 Feb 2024 04:59:34 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWd8rKvRi3uH3xm2x+Jn6hMbNTU2ule+Gpo6QcY7OFZcQHp2ARHF7HWYnlgaBlGYjH6GG8zzMwE9xH7kgeBJ+J26cenqmlZh+1BAxXLbauaIrQ+44rw1hhFlivS5rwzfiyQqCuXgAy+ETuOkDwQPjvEmoNAJBEsTQc+CnB81EiWJNXqqIqHHnOM6IWgDa78Jnlsy0GzQSKAF1366dR3y5a60jgd4SZE3dNkn6yRGvQbeVf0KpGhRrWrrDy2XDLqjh5ddFR8cFBl812hLftSVT+BN5nWwLRmysF/8FH0GqXg+bMZZoLQ8HPj Received: from [192.168.2.107] ([79.115.63.202]) by smtp.gmail.com with ESMTPSA id m10-20020a05600c4f4a00b00411e6243e70sm1909500wmq.12.2024.02.14.04.59.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 14 Feb 2024 04:59:33 -0800 (PST) Message-ID: Date: Wed, 14 Feb 2024 12:59:31 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] spi: spi-mem: add statistics support to ->exec_op() calls Content-Language: en-US To: =?UTF-8?Q?Th=C3=A9o_Lebrun?= , Mark Brown Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Dhruva Gole , Gregory CLEMENT , Vladimir Kondratiev , Thomas Petazzoni , Tawfik Bayouk References: <20240209-spi-mem-stats-v1-1-dd1a422fc015@bootlin.com> <7b3c08b0-80ed-4409-96d4-d55b938df6f4@linaro.org> From: Tudor Ambarus In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 2/14/24 10:59, Théo Lebrun wrote: > On Wed Feb 14, 2024 at 10:29 AM CET, Tudor Ambarus wrote: >> On 2/14/24 08:51, Théo Lebrun wrote: >>> On Wed Feb 14, 2024 at 9:00 AM CET, Tudor Ambarus wrote: >>>> On 2/13/24 15:00, Théo Lebrun wrote: >>>>> On Tue Feb 13, 2024 at 1:39 PM CET, Tudor Ambarus wrote: >>>>>>> /** >>>>>>> * spi_mem_exec_op() - Execute a memory operation >>>>>>> * @mem: the SPI memory >>>>>>> @@ -339,8 +383,12 @@ int spi_mem_exec_op(struct spi_mem *mem, const struct spi_mem_op *op) >>>>>>> * read path) and expect the core to use the regular SPI >>>>>>> * interface in other cases. >>>>>>> */ >>>>>>> - if (!ret || ret != -ENOTSUPP || ret != -EOPNOTSUPP) >>>>>>> + if (!ret || ret != -ENOTSUPP || ret != -EOPNOTSUPP) { >>>>>>> + spi_mem_add_op_stats(ctlr->pcpu_statistics, op, ret); >>>>>>> + spi_mem_add_op_stats(mem->spi->pcpu_statistics, op, ret); >>>>>>> + >>>>>> >>>>>> Would be good to be able to opt out the statistics if one wants it. >>>>>> >>>>>> SPI NORs can write with a single write op maximum page_size bytes, which >>>>>> is typically 256 bytes. And since there are SPI NORs that can run at 400 >>>>>> MHz, I guess some performance penalty shouldn't be excluded. >>>>> >>>>> I did my testing on a 40 MHz octal SPI NOR with most reads being much >>>>> bigger than 256 bytes, so I probably didn't have the fastest setup >>>>> indeed. >>>> >>>> yeah, reads are bigger, the entire flash can be read with a single read op. >>>> >>>>> >>>>> What shape would that take? A spi-mem DT prop? New field in the SPI >>>>> statistics sysfs directory? >>>>> >>>> >>>> I think I'd go with a sysfs entry, it provides flexibility. But I guess >>>> we can worry about this if we have some numbers, and I don't have, so >>>> you're fine even without the opt-out option. >>> >>> Some ftrace numbers: >>> - 48002 calls to spi_mem_add_op_stats(); >>> - min 1.053000µs; >>> - avg 1.175652µs; >>> - max 16.272000µs. >>> >>> Platform is Mobileye EyeQ5. Cores are Imagine Technologies I6500-F. I >>> don't know the precision of our timer but we might be getting close to >>> what is measurable. >>> >> Thanks. >> >> I took a random SPI NOR flash [1], its page program typical time is 64µs >> according to its SFDP data. We'll have to add here the delay the >> software handling takes. >> >> If you want to play a bit more, you can write the entire flash then >> compare the ftrace numbers of spi_mem_add_op_stats() with spi_nor_write(). > > It is unclear to me why you are focusing on writes? Won't reads be much It's easier to test as the SPI NOR core will issue a new page program operation, thus a new exec_op() call, for each page size. > faster in the common case, and therefore where stats overhead would > show the most? For cadence-qspi, only issuing command reads (reads below > 8 bytes) would be a sort of pathological case. If you can serialize the reads and do small 8 bytes requests, then yes, small reads are the critical case. Not sure how common it is and how to test it. Again, opting out is not a hard requirement from my side, you're fine with how the patch is now. But if you want to measure the impact, you can either compare with small reads, as you suggested, and with full flash write, where the exec_op() calls will be split by the core on a page_size basis. Cheers, ta