Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp200961imm; Thu, 26 Jul 2018 01:50:43 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfi9DClB6YgJGsYJJsPFYDOlDL+BPCAiQmmhNsAyQ+1/1vTLMmuyppPrsYKH3DZGvesBQQe X-Received: by 2002:a65:6411:: with SMTP id a17-v6mr1044864pgv.287.1532595043624; Thu, 26 Jul 2018 01:50:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532595043; cv=none; d=google.com; s=arc-20160816; b=VdLaxth5mhOSX4Bdwpy/Ol5NjHTJHzDt/Z3xazDg7IABkkVcEdWYfVw4HjnI1vcy15 OlA5aFPPlGKJEC4F/WJYViC03DDxtS7O7LVzy5+6f/BzMsv0QXcghe4HHwfpiadA/tk8 PtLf7bfQtjRIgYb3RXAG5pW58JQf/dyL1h3Pg3Mr4434/dHIAw5j9KfiKr0/Exi4flfB IiHaZDnWuvZUHlbOSmSx000xP5uQpSJzFtsFs8B1ocPxAPiDXK1vJtjN+NekmfsTviYA wrToWwbx9cZTcI5AdzCvV0+vBivglNL1guaK3YTx7q9vJ3YciIg5z7RW+d7ISApQTEAP TUvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=AtUdswberurTTOXCfPPgHavSTf5uHPImUrFx4dyDFhA=; b=QlHOHXKgGMN03ttzZNasCxLEk8T9017GfDkFeiQQgQB4n7epxWlg9dWYpQW3mFN3IW faeu+MsJSCGzztMmOTCI8TC0Zf8hlSqpTrh9P73o7aQiotJF1q1jKgH5DTKZ5DIfshs0 tqv0x46esrWPdY9pdj5WowDLzf/8PyzMJnB9ovxnavYeB8fGqNdRi4DrxArIJ8AjPStT HhtbJi+S6PuLfPkWlXMZ3i9hE92BZl16QmigDFgohavSLck2RgIC5p36f23mBnp5UVHv ynX0DVhXd+LwqoaAU2VDiWZzb7Fjc9XQ898jGGmpwxtwMGB95IiV+RCO9iDf+5zDrgSJ JjQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qkUNC6M8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p77-v6si895246pfj.294.2018.07.26.01.50.29; Thu, 26 Jul 2018 01:50:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qkUNC6M8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729186AbeGZKEt (ORCPT + 99 others); Thu, 26 Jul 2018 06:04:49 -0400 Received: from mail-ua0-f193.google.com ([209.85.217.193]:41995 "EHLO mail-ua0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728825AbeGZKEt (ORCPT ); Thu, 26 Jul 2018 06:04:49 -0400 Received: by mail-ua0-f193.google.com with SMTP id w7-v6so579404uan.9 for ; Thu, 26 Jul 2018 01:48:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=AtUdswberurTTOXCfPPgHavSTf5uHPImUrFx4dyDFhA=; b=qkUNC6M8FNtu/jM1ypsPP/KfA/XqUGMi5Q5azWfHmZgQ/cLUGJcWcE112nF05OV1Pz kG6DfjjiF13HBCQLTbwJ6aFHQCBudfPPZGejtxcL75sEIbGRcOcVVRYWygQdiUjsVFNa 9WiJ3QCU2kjsJRXSiOz4iv9Ok3bLkPzmH89EE5/p/u6YiUU4b0Bf8IuxRa4YDBJrlDhW kHXJrmsUx3zYzrp/rnFToY+eaUZd/zVswWw/weeel0evimbtCFnqydUa5P5z6JxoBShZ Ay8f7e8W0lzjyv+rXhnMQKg43DDJA0b/i+4aY+dBh3lfiGCMTLgWZelgjKmoEjrHXXEU H/gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=AtUdswberurTTOXCfPPgHavSTf5uHPImUrFx4dyDFhA=; b=TH4xi8l65xwEqen00wB5wteNk3ORbjNibJ+yzVbj+6Fvh8V3sBYtXK/6Z+kmRo3G9u gn6BtYWUCeyCOxtJ1V0ktuxxeRk/IoUunspdJuhV3hMWS+wGft3cpy2EYujvi4QwNWSb g1123E+XKHu94L6EwYY3QKb4t6wuanRgh3OZEcg6NdnTXKq93fxXuvXIpwBYkZ97zPJK SZyg7Q0ko47toptosAZRIOcj7+YTkNk3CTjp1op4NpljG71AcYQKS8gtiQwAS05VisY0 yVN3VRSLN1Smr/JcV7jokx1Q1C/dJ/vlRBxAcokEJ7skPqYYC+buMwGAq2xEEvb5lYjd 18vg== X-Gm-Message-State: AOUpUlHZiTSMBgLPuWieh37ZFt6s1+jMbJ4mL2s0NCzjh5tY2964n5Wq mJEdk9+mkJm3NrM5wpMVjBFt4pwTDXsa3uajK4I4W6K3 X-Received: by 2002:ab0:6037:: with SMTP id n23-v6mr705343ual.28.1532594939549; Thu, 26 Jul 2018 01:48:59 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a67:2149:0:0:0:0:0 with HTTP; Thu, 26 Jul 2018 01:48:59 -0700 (PDT) In-Reply-To: <1532592471-21177-1-git-send-email-wei.w.wang@intel.com> References: <1532592471-21177-1-git-send-email-wei.w.wang@intel.com> From: Andy Shevchenko Date: Thu, 26 Jul 2018 11:48:59 +0300 Message-ID: Subject: Re: [PATCH] linux/bitmap.h: fix BITMAP_LAST_WORD_MASK To: Wei Wang Cc: Linux Kernel Mailing List , Andrew Morton , Yury Norov , Jonathan Corbet , Rasmus Villemoes , dgilbert@redhat.com, Matthew Wilcox Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 26, 2018 at 11:07 AM, Wei Wang wrote: > The existing BITMAP_LAST_WORD_MASK macro returns 0xffffffff if nbits is > 0. This patch changes the macro to return 0 when there is no bit needs to > be masked. > Can you provide a practical example of what's going wrong before this patch applied? > Signed-off-by: Wei Wang > Cc: Andrew Morton > Cc: Rasmus Villemoes > Cc: Yury Norov > --- > include/linux/bitmap.h | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h > index 1ee46f4..12af3d7 100644 > --- a/include/linux/bitmap.h > +++ b/include/linux/bitmap.h > @@ -194,7 +194,10 @@ extern int bitmap_print_to_pagebuf(bool list, char *buf, > const unsigned long *maskp, int nmaskbits); > > #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1))) > -#define BITMAP_LAST_WORD_MASK(nbits) (~0UL >> (-(nbits) & (BITS_PER_LONG - 1))) > +#define BITMAP_LAST_WORD_MASK(nbits) \ > +( \ > + nbits ? (~0UL >> (-(nbits) & (BITS_PER_LONG - 1))) : 0 \ > +) > > #define small_const_nbits(nbits) \ > (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG) > -- > 2.7.4 > -- With Best Regards, Andy Shevchenko