From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (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 EE9CB313543 for ; Mon, 5 Jan 2026 09:28:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767605286; cv=none; b=hsxQvEvxuVWHB2jN/nnsM9HP3tdZG/xdqv0nJSpiN7DSPG+3hnNRv1QjaZsDaFT/x1RGGp20J/VHHEeYoUy28cq06jbfuM907yruZl8z64pG8PHVrqrkDffxUbxBWAQ/BTCMakbgffYLERQdjg/pGkRGEEHH1O+oPqDkTg4kVcw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767605286; c=relaxed/simple; bh=LUBqn4Ylu7k53HZu4lQqsEMpRTV2mIhD9a8O6isq6MA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=l1CPKZ1UEMuEBgLrtyeBN9Bx1Bf2SB3EH3gIN+XapbAcqiSJLvKe4EaHkW6+sYOCmn+LSSL+9mZXlJIOLYTg1eCjYW+0mA5f659pwdfP8XsFF0bMoLl8JFNr1NOzI5j9QpvHaw+ERhlwyBrGGLTNWmsL3VR4j5AmZgLRZjGDSGE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YWC0/LoN; arc=none smtp.client-ip=209.85.210.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YWC0/LoN" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-7b9c17dd591so11388231b3a.3 for ; Mon, 05 Jan 2026 01:28:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767605279; x=1768210079; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=nQIZ452wZXIK57t7CDqSPjoLHYNUHDQ+2nk1XIU16DM=; b=YWC0/LoNZnVjPDkmZYt659X7a3/xGc7NTkbSVt2F+3qfqjywE77kamuzBv6ilMNIF3 lmrd9s7+Ff+8RGWcwfHBMp0t6+HqJYpVxLPisdrX5bWIp1eMC9qaR2/RB0JMvSnOcvMT JdHpd/QeY0GmxewsMsePEz8qRnXxKEJqL8f/aQeRGPHZomNSM9riYAhSIrVBeq6ap2kx Qg8U2L3S63ZFvIy0ZLT4Iq48Kti5L4PQuWuiNjzkE6DjI4OOd+Qrwz1kMzQx9qxngBgC o9zjXe4q+BJrAtj4lpCeuqjecZoKLAYaawBHQyaxv1J3LqMRHQgYGraCBbMTm86QLWtV iZsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767605279; x=1768210079; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=nQIZ452wZXIK57t7CDqSPjoLHYNUHDQ+2nk1XIU16DM=; b=fpy047lUquhTCpF0VCTVSCiC5EjE1RnVf4//IbuSkANavLFickXPDlUN3ksY1lOYQ3 vxa680qcu81OwclVe1UBu4I75PN4kex7hS9osZcV1xNwPA7Mv+0TIT8hzTs6/PMTN8qO lWwd/jUT9sFEmYXF8gWsDwuASVvHNG+bROTdDqHCy1RlXCjhbIs0wCAD6xWpojZR0Qga KfOBCeV38iYJrXuaOzMYm+osUX5WIvkNyKF5CEEBQ4kzwT7VzXYKU1cbEt/tji5uXHpo 446yyAAhyCI7eW0IYiqseDSl6bzCy7xQithyHyAwjR8X8/TYZEw3P5oNzTYG/bnWx/vL cITA== X-Forwarded-Encrypted: i=1; AJvYcCV/nN3lg8t1E2YGl5fyO4h8Du7L93tKxT0FK4fattcH++Akl+XUzVKqGPU99h2uFIqpX0L1Q1YNwq95eTQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yzrny6gYWaOa/SW284vJ3YxhcToLHwMZmGMf9xqNz2xqMM0Q7Rb nJs2vwfI1r6UOKN9lFjC4SJOAcMRMr5MVT2/xBM9Lqzd5lptV2oe8UoN X-Gm-Gg: AY/fxX7pSSpWNInOr+8Ac+tgKWeI6pCT7U2ccSfFGYfptVZZkUNwp9GAbcfE28wpf5r 1aPu5uOvhk1MrjxswTwJNKT7zyM0lSMKFnfTwJ6Ftb6uArMJE5QE/5ObetZc9AymT33uB/SNWQr SBvKzkYxAGtMHNr1olm7wTpyDhk6RtCrFdW/7wx5gHlA5Jv1rOfqeRX9Ps22cg3vYBpKpLVTdBU wn4CZf4axk2RpKNXJ/EIkSrfiWVRMiHg5lkaT4gAyowPHT7jkdBmXvd5pGrPe9/O0axEdcMlywH s8D4FfCdtscEUYYovg70d+vber0pSSdfYlDSTii79djQHELcKmoQTV8JLBtu2UC22HdBs0S4azZ CBBCWnT4vNp93OID8+Jl3mK93GfPazkNBtwVRs3EUwr7r31Y6HmHMUnky9+QrHSf2JZMtutF0M2 aRKq61/DaCbSgaBjhhPUYCsapmB0zQAgHs X-Google-Smtp-Source: AGHT+IEZmNkq8Gl/dnJOg3s3RWvfca6b9cqNrss8LiqWrUnkpu+7dey1SrWISomWv3jO23drZv2kBA== X-Received: by 2002:a05:6a00:4509:b0:7e8:4587:e8c1 with SMTP id d2e1a72fcca58-7ff6647983bmr40451269b3a.52.1767605279080; Mon, 05 Jan 2026 01:27:59 -0800 (PST) Received: from [10.4.111.0] ([139.177.225.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7ff7af35f37sm47508520b3a.18.2026.01.05.01.27.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Jan 2026 01:27:58 -0800 (PST) Message-ID: Date: Mon, 5 Jan 2026 17:27:54 +0800 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] iomap: add allocation cache for iomap_dio To: Christoph Hellwig Cc: brauner@kernel.org, djwong@kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, guzebing , Fengnan Chang References: <20251121090052.384823-1-guzebing1612@gmail.com> From: guzebing In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 在 2025/11/21 18:22, Christoph Hellwig 写道: > On Fri, Nov 21, 2025 at 05:00:52PM +0800, guzebing wrote: >> From: guzebing >> >> As implemented by the bio structure, we do the same thing on the >> iomap-dio structure. Add a per-cpu cache for iomap_dio allocations, >> enabling us to quickly recycle them instead of going through the slab >> allocator. >> >> By making such changes, we can reduce memory allocation on the direct >> IO path, so that direct IO will not block due to insufficient system >> memory. In addition, for direct IO, the read performance of io_uring >> is improved by about 2.6%. > > Have you checked how much of that you'd get by using a dedicated > slab cache that should also do per-cpu allocations? Note that even > if we had a dedicated per-cpu cache we'd probably still want that. I’m sorry for the long delay in replying to your email due to some other matters. I hope you still remember this revision. First, thank you for your response. Yes, I try to use a dedicated kmem cache to allocate cache for iomap-dio structure. However, when system memory is sufficient, kmalloc and kmem cache deliver identical performance. For direct I/O reads on the ext4 file system, the test command is: ./t/io_uring -p0 -d128 -b4096 -s32 -c32 -F1 -B1 -R1 -X1 -n1 -P1 /mnt/004.txt The measured performance is: kmalloc: 750K IOPS kmem cache: 750K IOPS per-CPU cache: 770K IOPS > > Also any chance you could factor this into common code? > For a mempool, we first allocate with kmalloc or kmem cache and finally fall back to a reserved cache—this is for reliability. It’s not a great fit for our high‑performance scenario. Additionally, the current need for frequent allocation/free (hundreds of thousands to millions of times per second) may be more suitable for the bio or dio structures; beyond those, I’m not sure whether similar scenarios exist. If we were to extract a generic implementation solely for this, would it yield significant benefits? Do you have any good suggestions? I’d appreciate your review.