From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (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 BB2D129BD9A for ; Mon, 9 Mar 2026 17:04:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773075845; cv=none; b=D9d3l/0hzA54xuxEn+qceNZHiG/YhLPmfl+DU46YVIbmGUuKhvbpYpx2Zm83UJaZyo5SMUFkRfcSZtE/bZ1cjwXNs+q689NiiIgx1hvM2LSGrpG8XIVRzWoDisTDpoi0no9UkdikWVDPczEM/7qHGHjh3WHBuOU0C0iOvOXPmvA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773075845; c=relaxed/simple; bh=+NRQ2z+iGFTqYpUWkSuD+VeuVTuMeLBq9U1dIg9HPZg=; h=Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject: MIME-Version:Content-Type; b=LwTUj+TWpDU6G8hfBQxyqFEk0+RP34z0AxkOhGhp29rmheDNTZZxId/dTx5nSfHrsXFqmY0VDM6Gr/Gp9m4pPilvrC8FTpiSLkjRmHoauKo5ohpNl2Am3wR80jiv7UszHMXKSomW54YQo75loOr/AIpfWqj9ePHudOxTa7kgr58= 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=m72T44+B; arc=none smtp.client-ip=209.85.128.50 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="m72T44+B" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-48535a0ef86so13716625e9.1 for ; Mon, 09 Mar 2026 10:04:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773075841; x=1773680641; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=+NRQ2z+iGFTqYpUWkSuD+VeuVTuMeLBq9U1dIg9HPZg=; b=m72T44+B+cHsmB9mQ6NT/HuyUimkASUYZPLrdIeiZ9ad9BXv1Sjb/lUsaRIIkXbqNt GCHLXe/g9RJ5bmsHiuRh6dQ838c2BeFb7xzL6gmZxz3646xA64CdbvS1A53NlHXFLvdZ hrMkDnnBZcm5u6Z5YDajZkqSlXnufAHgDxm70dT2WP8hZ4qzJ8+BityniHA+DGDauKGI 6uHbJ20Q7MXIk0PC/dK+DPLMkKNdeOh4EU5yQ8ugOZ+HHM3hSN+c5x+aA4el0HnIdd4d 8HREqEf1r3Q7FtYRZ1W/6ENJx+fJ/88s3z+YQ6qB5JdAsEHT7Yeb6yUQSpAPlDADCaR7 mlvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773075841; x=1773680641; h=content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=+NRQ2z+iGFTqYpUWkSuD+VeuVTuMeLBq9U1dIg9HPZg=; b=r29aRQjtnYBkHhvAY/mfOmDpGQVnXqSeARLDVRWko0rHtk/Jm+uQ/gQBtEmVn9LDEH OCKYGXB8+BvRh1tyv4guYT8uCS0r+AjrhmAsZ/yHY0ACwAcMniJT/IyHgQGcqRgAbp0E 6xWn3xUPBftZNp5oMq0YcjUqr2CI1uqqpRkNwfcqO7cJgDxUo9/545fFhiCSSzaga6Zp orZp8YrFy96WJASaiyyf9QF1afUGbhvKX+j/nt9LEl7MdDQ4PjPjJGx6siz0raTcSO+w HgLeT92eLu9iorUXa6PnknA/dHytsWJYcYrjh2oFMbERI7xuTfKnVEPqem+IAezL+QeZ Dulg== X-Forwarded-Encrypted: i=1; AJvYcCUIOU/plbz/pUQRyD4ButhrtOaas+1gIwVCTGTktZHZIqvx1eCaoWO90mPfQ5AYjk9D5Rc2B7PKjK3RP+M=@vger.kernel.org X-Gm-Message-State: AOJu0YwIPc65wHzcnXpWEyG5WpWBx3KcvfsfxZyWX9x+c+6PMoBAwZ7d M0aogl/H9kls1dBxRRk7dspHLU22mu0InPM5SrI8g8uTEIXczD5aUsCFplDez8oiCuM1vA== X-Gm-Gg: ATEYQzz0McXgcVOztTpSo5M+gxaetlkK7Aby8gVUggML0vrqzNDoZMtzjAI7XPWY/gD Zm2XfDPKaMV2YMlZPWwdo4NiC5PqvCIMABX9goSd2Um7XXfb7oazJHJ+Z8PWeVMcHWrSGZUrfOW 32C5vVelwy0Z3wXPzHRf++PzB6ekLxePDwH0aiGA7/mIMMvX5pMAdBhe03aeL8UzEWvrF1hjQTw swnxii/iwohsMCi+0FX8jk5SJ/4L09YMkcgvjKN3s3nBBwOTm0dPfV5Dr9ZYQJMDZvV+UPvTImp ZRqYcqogEMS8C7GI+zAz09rMmgNWAdcgWZiMmkm9lqb250KMqcdsMCxTCcpbQqGIIYF0c1wqH5n grvANCgdaHWZmTK+Rb8Omw9b/3Bk8B4wrW1JcJpRkxgGwo2LLYg5MZcghzcLFNOrOQ90WbdWZDG 7evrrRcjKzaJu94oB1 X-Received: by 2002:a05:600c:3510:b0:485:3c05:24cd with SMTP id 5b1f17b1804b1-4853c0527dfmr56295505e9.33.1773075840609; Mon, 09 Mar 2026 10:04:00 -0700 (PDT) Received: from [127.0.0.1] ([86.1.69.5]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48541a6bc3bsm4770515e9.2.2026.03.09.10.04.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 Mar 2026 10:04:00 -0700 (PDT) Date: Mon, 9 Mar 2026 17:04:00 +0000 From: Josh Law To: Greg Kroah-Hartman Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Josh Law Message-ID: In-Reply-To: <2026030903-although-gratitude-49a6@gregkh> References: <20260301005836.2513391-1-objecting@objecting.org> <2026030914-task-stunned-21e0@gregkh> <07e2ae8e-e6e9-4def-9eb2-2c48ce6669b8@gmail.com> <2026030903-although-gratitude-49a6@gregkh> Subject: Re: [PATCH] staging: axis-fifo: minimize lock duration in write 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=UTF-8 Content-Transfer-Encoding: quoted-printable X-Correlation-ID: 9 Mar 2026 16:56:37 Greg Kroah-Hartman : > On Mon, Mar 09, 2026 at 04:11:25PM +0000, Josh Law wrote: >> 9 Mar 2026 16:07:50 Greg Kroah-Hartman : >> >>> On Sun, Mar 01, 2026 at 12:58:36AM +0000, Josh Law wrote: >>>> Memory allocation and copy from user space with vmemdup_user() is rela= tively slow and can sleep. Move it outside the lock to minimize the time th= e mutex is held, reducing contention for concurrent accesses. >>> >>> Something happened with your line wrapping :( >>> >>> And are you sure that your change works?=C2=A0 What is wrong with grabb= ing >>> the lock this way? >>> >>> thanks, >>> >>> greg k-h >> >> The issue with grabbing the lock before vmemdup_user() is that the alloc= ation and user-space copy can take a significant amount of time and can sle= ep. > > But what is wrong with that? > >> Also, it's just to be more efficient haha, and yes I'm sure this change = works, I own the hardware, and it operates better... > > Great, please put the performance numbers in the patch, that will show > the need for this change. > > thanks, > > greg k-h Hi Greg, Fair point. Because mutexes are allowed to sleep, holding it during vmemdup= _user() isn't inherently a bug. The issue is that while it sleeps, it block= s other processes from acquiring the lock, which bottlenecks CPU usage time= s slightly Perf numbers: sys before: about 18 seconds sys after: 14 seconds V/R Josh law