Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp600002lqp; Sat, 13 Apr 2024 10:14:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWKyrXveet5rOuEf7BHnk2oFks4V+JycduSuDDp4MQvIONR+FmgiAw968PcsBvWnG4lg5u/h7WFHJT6blAQJ2OKO+ykPeCRnW5GDcdOJw== X-Google-Smtp-Source: AGHT+IECUQxUm9fdhaxRX7BYcL9UPMr9h7JRsVFI0QWN7+TN0CGfWxfZ+UySPPEMVSaFpcQt1qSz X-Received: by 2002:a05:6a00:cd3:b0:6ec:f282:f4ea with SMTP id b19-20020a056a000cd300b006ecf282f4eamr7264291pfv.34.1713028460137; Sat, 13 Apr 2024 10:14:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713028460; cv=pass; d=google.com; s=arc-20160816; b=QARcxCTVBkhGdzdS5QVXuwG1y4DK2A8FFN0RiMjEduntFUgQcflh6t3ciBzLL9ezzi hO5rJSYnGOYsvdGYYLRuvZrv0TpJu0IheDaLzxJEF1lm3IGWKlf3Kmeqxgq8Ptl07L2u XAQQRVE2X4xquGcojU39P04GHQKE5ZYIoQeT6wkHUA2Ijhv0gLTSOHRZ7yNATXPuzMdv rmqytgIqNQyslIy8Q8aVqR9lhqrqngDYgu/3M4V8PDxvB/74U6dIv/BJJIzyTIxU7yTp 0ljF8xxSRliaWGKodLY0wlgq9DIrUqjfyriWxAXoHSQgsTDIXU6LuQW0NfVhxOhvGz6Y rLCw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=NNXqxRVe9CVDdGjQD7K7O+b7VqxredJ801rqRgpXoHs=; fh=QWCYIqOsDH5G2Gk5xKKTvrq7jP5Z5vJpL5Hmi5X1Bo8=; b=A71CF+Ig50aKYr3zbMVintgiUq+FWIelONoRx3G9s91uVe/F+jh/KGYVQJ/2voAL8W bvloRSTf/1sTjAaZ3YFfyZ+UpCDrObVIvHFjqe2vUJV2uMPSZwCZjuX6nHcylfApY+ss XlXcqnAfLALuZR4dNHwtJHhMPiXXlA4LVphy6KPfaFf+GVhr3E424Rhgs5rwcqanoTBz 9Ja2MbFyCAB6k9gbmJ8BfOesSNTID6Hvj+rZkguS97P0PCzZbUS83g/ktGeeXdWlY3sD o4C52lK7P5618OXb4bYSoIZqsnjAwATMNr/MeVx5Fovghdv3Nq3HEmCQYpMIoO4Ryckk jfkA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=JcMsgQRc; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-143830-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143830-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id e19-20020a63db13000000b005f069faad54si5172037pgg.615.2024.04.13.10.14.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Apr 2024 10:14:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-143830-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=JcMsgQRc; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-143830-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143830-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id CCED8281F9C for ; Sat, 13 Apr 2024 17:14:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B46EA4D595; Sat, 13 Apr 2024 17:14:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JcMsgQRc" Received: from mail-yb1-f177.google.com (mail-yb1-f177.google.com [209.85.219.177]) (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 97A6F482D7 for ; Sat, 13 Apr 2024 17:14:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713028454; cv=none; b=lP74jl/OyLE2bFI76Je7RpwGO8/pLD24M+vpzmPU5fJ3xJ9ynRjALkN9evfcudPzKz1MkWwfMVxPcvDAEX0KxmEZtEUVRqmlSvPHcrYvIh+XhvnxdDgphrzBK0ILjmMkmVRSQz2RFms9HV9AMZu4yUU573dVXYPvBW+9v2vNZyQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713028454; c=relaxed/simple; bh=XcTA/luCjnxFy1jTuldTqBkbaCVB2SCFFFKdCPF41D0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=EGQwgLvdTaGSFEsXR6BCAg+QwTFHyWSl85rWy5so3UZbEf2kmn1qDyPK1/AuwqI1B03fcSW5pRjv+crK4l7z9+5fcSd7QaCqGJ7PoMACIVDA4pt2BUl2a2Xlf0f4zr5Ttp8NySm8mqPjJFFi1u9jHEk4QUC+L81/GVh44t88AmM= 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=JcMsgQRc; arc=none smtp.client-ip=209.85.219.177 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 Received: by mail-yb1-f177.google.com with SMTP id 3f1490d57ef6-dbed0710c74so1578059276.1 for ; Sat, 13 Apr 2024 10:14:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713028451; x=1713633251; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=NNXqxRVe9CVDdGjQD7K7O+b7VqxredJ801rqRgpXoHs=; b=JcMsgQRc8IR1wSLV888l3xVOHyZ+pV204B2fFWoEWLDRHNe+HoxlZarJ0BfOzSGpP5 41rLWrMKaJFRBvGw2Qi0QxKpdye3Jx2owbHR53MbWwWZyHzM+S/RBiyeaUpJfKKw5NRA A7pyqvZjmyVlcyvPxMJ4vCwhVNjy1DVhi80pP/kduPt50esBQY4mOQV0kraB+hh5DkP8 UlpetfW7CG7zu/18Cho50jaQxOvoMrGKdIgzzAwMf7tEftpMZtZuQEZ0390ZJ+dyraiw gv2i5PjCyZ41fCM02WKR7f8VJp8tygjr+b7EPP/k3Kc/VIAm+ufy1DdbAa9TjjJpGx2I LzVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713028451; x=1713633251; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=NNXqxRVe9CVDdGjQD7K7O+b7VqxredJ801rqRgpXoHs=; b=LCT3pHP8FqAEfJHh+Uf5gZLQIExIxjf5S6S3irdGPoZFzKD8Nw8eiOnxNir9mqip57 0A/mQ+VaHOZ8W05gVVFlKZmNrBF3EnIiTaE4Y6cWSwzvDymV4zLHIrTKyPqocIOW1+jy N446FQIDGQ5ImzRb8IpMAl3KqBqIZX3/dufkDjwj9RDAs1oO3nQSbBK4HQwof60aer7v qEjHu7dM4+0mpy0hGP56iZP2AK7CYxGohSU0GF2EPdh6T9HfwWhuYSAj6K4f0zz01v8s jqkzmIaKgRqa3wbIUUZnMJT3hylV+jqwnoKudDWH0Cii7AkIzLOId3ZYmIRDhoqcOkBC mQNw== X-Forwarded-Encrypted: i=1; AJvYcCWnu1EIL+7OoMRGkdBcZAxai7m0oREri2Aiygk//Njwo/1t1NtMS3vCK1ss6NpAIfS07D6JlXX9lDG7I+7KAF/Lxgx9FDfDm11/hQvv X-Gm-Message-State: AOJu0Ywc+b/xcfQZuh0mbFdJeQz0fAIES/Pl8ltbWjJhoIruAGjK+ixR 8wrIW16oo/Vah48fIH5WBK4YBWcezHCkmxuquTQYPzgc8NoLl5Jh X-Received: by 2002:a05:6902:1024:b0:dcd:19ba:10df with SMTP id x4-20020a056902102400b00dcd19ba10dfmr6222959ybt.56.1713028451509; Sat, 13 Apr 2024 10:14:11 -0700 (PDT) Received: from localhost ([69.73.66.55]) by smtp.gmail.com with ESMTPSA id u125-20020a256083000000b00dcdb7d232f9sm1262587ybb.4.2024.04.13.10.14.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Apr 2024 10:14:11 -0700 (PDT) Date: Sat, 13 Apr 2024 10:14:10 -0700 From: Yury Norov To: Chin-Chun Chen Cc: linux@rasmusvillemoes.dk, linux-kernel@vger.kernel.org, Chin-Chun Chen Subject: Re: [PATCH v2] include/linux/bitops.h: Fix function fns Message-ID: References: <20240413061204.10382-1-chinchunchen2001@gmail.com> <20240413155635.11486-1-chinchunchen2001@gmail.com> 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=us-ascii Content-Disposition: inline In-Reply-To: <20240413155635.11486-1-chinchunchen2001@gmail.com> On Sat, Apr 13, 2024 at 11:56:35PM +0800, Chin-Chun Chen wrote: > Modified the function fns to resolve a calculation error by reducing n first to correctly determine the n-th set bit instead of n+1. > > This commit improves the accuracy and reliability of the code. No it doesn't. Accuracy and reliability is tested in lib/test_bitmap.c. Have you tried to run it before sending this patch? What error did you mean? How does pre-decrement over post-increment fix it? > --- > Changes since v1: > * Clarified the commit message. > * Fixed the incorrect operation. > > Signed-off-by: Chin-Chun Chen > --- > include/linux/bitops.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/linux/bitops.h b/include/linux/bitops.h > index 2ba557e067fe..5842d7d03f19 100644 > --- a/include/linux/bitops.h > +++ b/include/linux/bitops.h > @@ -258,7 +258,7 @@ static inline unsigned long fns(unsigned long word, unsigned int n) > > while (word) { > bit = __ffs(word); > - if (n-- == 0) > + if (--n == 0) > return bit; > __clear_bit(bit, &word); > } > > base-commit: 8f2c057754b25075aa3da132cd4fd4478cdab854 What does this 'base-commit' mean? Chin-Chun, if it's your first attempt to contribute to a public project, you're very welcome. But you have to be more descriptive on the error you're facing and trying to fix. The best practice is to provide a test together with a fix. Thanks, Yury -- It may be just my paranoia after UMN and xz stories, but... I googled for this person and the email and found that it didn't appear in public domain before now. Let's see...