Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4375720rdb; Mon, 11 Dec 2023 18:28:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IHzvJnm/b9DAbtz0bhI+3HG5tE1hd7LmUccy43GrkW1invtQ7ZFKyZjI33HgTcx5go+qwIA X-Received: by 2002:a05:6808:120c:b0:3b8:b063:ade2 with SMTP id a12-20020a056808120c00b003b8b063ade2mr5445521oil.63.1702348136212; Mon, 11 Dec 2023 18:28:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702348136; cv=none; d=google.com; s=arc-20160816; b=KI6MBNV1/J/LHXSnD8no8B1SK6xvMbSf7CiI5RaO5CL/PAikaZgOVVhBnBW6/0ejr+ brbemX6CN/fKV88y4ErmDIHDnHPxa147zjqprl0rvZWAIsj7acHrcjuxPlxeAELo/3IN HU6IAJ81AOUSferzJZj2do1nn1fSRveodUyg3gBxOP64J1Q4aJAATXKKjqUWPAp40qAE 0XLk+SbYrbqnO3ROjVd9KefH4CQ7otHN4RxweBmap+CxsVMdkYZ1t9ieSbK/wIMozqv9 2a4re0yfOmwgc0tZQVXsj0iY0cc8Hu3zpl/iKcfYZPYSEjQRq3WR0cTVvKW6r1AV3W3m wEKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4CKJG0QWFDRGpjAibRGhHIP11SM03HdEpZd2mC7AZ0Q=; fh=+YcVigSuoCqMRHH+h9JGZGsEUjb5TQq05z+vmkGHwIY=; b=Gl9VCBXam4XH2TCPkOpJoSUzPlSkoNbCQ79vzOLVlXqe3La282J03TktZ04eBcxGyM d0kxLFYCJv1eCZ6nvt/aIEDICaB3+aPmnGbb7IUSPjSWOaJtRrTbMFT/yp1Wn8PRl566 duJHuZxMgvat9JfsHZW3rPh9Dn2YyHMOOqcf9hLKaDBt7azZQ3641XRhJOfDylxFThap Ph6VqRHeSMkIUL4iM1wLdF4AQLq2fco4Rjbnsa4v4yfpEKOJMRtJp5tT3gX5QhTQqnCj sbKH1hFGa66PriDOnAQFWX+2xKKQb3GpjN4VlC/N+FbJIQNjW7WLSYIoKW8Rvf4H0t7z Mx5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Gw2B8i2Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id x13-20020a056a000bcd00b006ce702c5c48si6688108pfu.359.2023.12.11.18.28.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 18:28:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Gw2B8i2Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 36F0F804E700; Mon, 11 Dec 2023 18:28:55 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345779AbjLLC2n (ORCPT + 99 others); Mon, 11 Dec 2023 21:28:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232511AbjLLC23 (ORCPT ); Mon, 11 Dec 2023 21:28:29 -0500 Received: from mail-yb1-xb32.google.com (mail-yb1-xb32.google.com [IPv6:2607:f8b0:4864:20::b32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B64BE8; Mon, 11 Dec 2023 18:28:17 -0800 (PST) Received: by mail-yb1-xb32.google.com with SMTP id 3f1490d57ef6-db53f8cf4afso4217026276.3; Mon, 11 Dec 2023 18:28:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702348096; x=1702952896; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4CKJG0QWFDRGpjAibRGhHIP11SM03HdEpZd2mC7AZ0Q=; b=Gw2B8i2ZDxUP+oP5D9HXJGW9mgoGNCdB+aBNZImdcfGR+Z4vuS0rjdz0qOy8bIQv3A l6zfgaua0++Bj6lkn6d0/Fklf11Aq891lJKqooLWpqdIlD4R2dMLHVQvmdP/eRfJyJo9 3hnqkth/I5gJo4hr9hX0T8f13KqkWEgvQ+CPJXfFolekk7IQSx0UjGFbTtUD2fe9WqaE LLq+vSs03pTIfwxsrFxw77/En5DP6OGVX9n3ZIp3Acj7wmP7TC9wyEMSs3wphJRH0tQU UsuESDbXyD68iRepKKzgIXYIW1xi9CHV28qMl6+LnMfx0V6c+j6031AK2EOWjPA+HwEm 0zVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702348096; x=1702952896; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4CKJG0QWFDRGpjAibRGhHIP11SM03HdEpZd2mC7AZ0Q=; b=OletdryjyntYLxSDZwtyj44bdClNuZfHfbOwW7xkWqxJYtd2nzT8jaR6zcwEQ/p1A2 L8gTnbrbiQpp28BgmOl2uwxdgFVRX1oxuhkWMz/UsdjQEGOVWbvNNvK3WSQEuoqfdN5W RvpZJs0a/k80/Qc0T+rl5cfl9nmAyXaJyO5TKo7ofadOX0PlQ7zphOpIAwjsSBuVESFv P0g7zeNm97ag2iuMT4dwgLmV1peBo0NiJokdY7tX88/Dj3eTHIfClPGx7mkyhGDlNJfR GmeSeoFOzZd3DVta7JojbBmTTc0aam+X82BdtMhY5KqT+cY9O8LtSmdcTj6S3pJujxCK sknw== X-Gm-Message-State: AOJu0YzJgFA+DIy/AkBjZ/qGdWXhA3mqN4+TvOtLusloTz/YbdcE+6ix 7WyYnHgx3rWvxa8q5YDCsR2pjuG4rUF05A== X-Received: by 2002:a05:6902:1ac2:b0:db5:48f9:aff1 with SMTP id db2-20020a0569021ac200b00db548f9aff1mr3726685ybb.21.1702348096184; Mon, 11 Dec 2023 18:28:16 -0800 (PST) Received: from localhost ([2601:344:8301:57f0:38aa:1c88:df05:9b73]) by smtp.gmail.com with ESMTPSA id g13-20020a258a0d000000b00d8674371317sm2881700ybl.36.2023.12.11.18.28.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 18:28:15 -0800 (PST) From: Yury Norov To: linux-kernel@vger.kernel.org, Sathya Prakash Veerichetty , Kashyap Desai , Sumit Saxena , Sreekanth Reddy , "James E.J. Bottomley" , "Martin K. Petersen" , Nilesh Javali , Manish Rangankar , GR-QLogic-Storage-Upstream@marvell.com, mpi3mr-linuxdrv.pdl@broadcom.com, linux-scsi@vger.kernel.org Cc: Yury Norov , Jan Kara , Mirsad Todorovac , Matthew Wilcox , Rasmus Villemoes , Andy Shevchenko , Maxim Kuvyrkov , Alexey Klimov , Bart Van Assche , Sergey Shtylyov Subject: [PATCH v3 15/35] scsi: core: optimize scsi_evt_emit() by using an atomic iterator Date: Mon, 11 Dec 2023 18:27:29 -0800 Message-Id: <20231212022749.625238-16-yury.norov@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231212022749.625238-1-yury.norov@gmail.com> References: <20231212022749.625238-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 11 Dec 2023 18:28:55 -0800 (PST) A plain loop in scsi_evt_thread() opencodes optimized atomic bit traversing macro. Simplify it by using the dedicated iterator. CC: Bart Van Assche Signed-off-by: Yury Norov --- drivers/scsi/scsi_lib.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index cf3864f72093..a4c5c9b4bfc9 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -2494,14 +2494,13 @@ static void scsi_evt_emit(struct scsi_device *sdev, struct scsi_event *evt) void scsi_evt_thread(struct work_struct *work) { struct scsi_device *sdev; - enum scsi_device_event evt_type; + enum scsi_device_event evt_type = SDEV_EVT_FIRST; LIST_HEAD(event_list); sdev = container_of(work, struct scsi_device, event_work); - for (evt_type = SDEV_EVT_FIRST; evt_type <= SDEV_EVT_LAST; evt_type++) - if (test_and_clear_bit(evt_type, sdev->pending_events)) - sdev_evt_send_simple(sdev, evt_type, GFP_KERNEL); + for_each_test_and_clear_bit_from(evt_type, sdev->pending_events, SDEV_EVT_LAST + 1) + sdev_evt_send_simple(sdev, evt_type, GFP_KERNEL); while (1) { struct scsi_event *evt; -- 2.40.1