From patchwork Sun Sep 27 06:26:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 11801817 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 53C8A139A for ; Sun, 27 Sep 2020 06:27:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3A82023A1E for ; Sun, 27 Sep 2020 06:27:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="agElJtWK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729291AbgI0G1R (ORCPT ); Sun, 27 Sep 2020 02:27:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:38637 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730429AbgI0G1L (ORCPT ); Sun, 27 Sep 2020 02:27:11 -0400 Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601188030; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=s0QJrlkrbBeq+eVwaFFCQP+CMSNcINM05HMlBIsX0V8=; b=agElJtWKbH5ue0DEtMH/BIK7ddUWCky/KF1uApapJPOhx51TEhYZKWu6pOEkAfc/rg8yp7 REZzEeXZ504uuKJNYHe9zcVyFdWpJEXXPCwVa2KKeJFqqKXKH5/UlUz9Ov+zB9ku5g19vW yHYnlyxISh4EWhTDMdOxxbXcx1aenkI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-244-TJuJ8QZDO5WC0GTCfTVHMw-1; Sun, 27 Sep 2020 02:27:06 -0400 X-MC-Unique: TJuJ8QZDO5WC0GTCfTVHMw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C148910059A9; Sun, 27 Sep 2020 06:27:04 +0000 (UTC) Received: from localhost (ovpn-12-180.pek2.redhat.com [10.72.12.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0EC4D7368F; Sun, 27 Sep 2020 06:26:59 +0000 (UTC) From: Ming Lei To: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org Cc: Ming Lei , Veronika Kabatova , Sagi Grimberg , Tejun Heo , Christoph Hellwig , Jens Axboe , Bart Van Assche Subject: [PATCH V5 0/3] percpu_ref & block: reduce memory footprint of percpu_ref in fast path Date: Sun, 27 Sep 2020 14:26:51 +0800 Message-Id: <20200927062654.2750277-1-ming.lei@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Hi, The 1st patch removes memory footprint of percpu_ref in fast path from 7 words to 2 words, since it is often used in fast path and embedded in user struct. The 2nd patch moves .q_usage_counter to 1st cacheline of 'request_queue'. Simple test on null_blk shows ~2% IOPS boost on one 16cores(two threads per core) machine, dual socket/numa. V5: - fix memory leak on ref->data, only percpu_ref_exit() of patch 2 is modified. V4: - rename percpu_ref_inited as percpu_ref_is_initialized V3: - fix kernel oops on MD - add patch for avoiding to use percpu-refcount internal from md code - pass Red Hat CKI test which is done by Veronika Kabatova V2: - pass 'gfp' to kzalloc() for fixing block/027 failure reported by kernel test robot - protect percpu_ref_is_zero() with destroying percpu-refcount by spin lock Ming Lei (3): percpu_ref: add percpu_ref_is_initialized for MD percpu_ref: reduce memory footprint of percpu_ref in fast path block: move 'q_usage_counter' into front of 'request_queue' drivers/infiniband/sw/rdmavt/mr.c | 2 +- drivers/md/md.c | 2 +- include/linux/blkdev.h | 3 +- include/linux/percpu-refcount.h | 46 ++++------ lib/percpu-refcount.c | 137 +++++++++++++++++++++++------- 5 files changed, 126 insertions(+), 64 deletions(-) Cc: Veronika Kabatova Cc: Sagi Grimberg Cc: Tejun Heo Cc: Christoph Hellwig Cc: Jens Axboe Cc: Bart Van Assche