From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934345Ab1J3R76 (ORCPT ); Sun, 30 Oct 2011 13:59:58 -0400 Received: from mail-gx0-f174.google.com ([209.85.161.174]:52892 "EHLO mail-gx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934247Ab1J3R74 (ORCPT ); Sun, 30 Oct 2011 13:59:56 -0400 Message-ID: <1319997593.13597.76.camel@edumazet-laptop> Subject: Re: >Re: [RFC] should VM_BUG_ON(cond) really evaluate cond From: Eric Dumazet To: Linus Torvalds Cc: Andi Kleen , Ben Hutchings , linux-kernel , netdev , Andrew Morton Date: Sun, 30 Oct 2011 18:59:53 +0100 In-Reply-To: References: <1319772566.6759.27.camel@deadeye> <1319777025.23112.67.camel@edumazet-laptop> <1319803781.23112.113.camel@edumazet-laptop> <1319813252.23112.122.camel@edumazet-laptop> <1319964754.13597.26.camel@edumazet-laptop> <20111030095918.GA19676@one.firstfloor.org> <1319987765.13597.60.camel@edumazet-laptop> <1319996494.13597.69.camel@edumazet-laptop> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.0- Content-Transfer-Encoding: 8bit Mime-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le dimanche 30 octobre 2011 à 10:48 -0700, Linus Torvalds a écrit : > On Sun, Oct 30, 2011 at 10:41 AM, Eric Dumazet wrote: > > > > Changing atomic_read(const atomic_t *v) prototype to > > atomic_read(atomic_t *v) is not an option. > > Why not? > > #define atomic_read(v) ACCESS_AT_MOST_ONCE((v)->counter) > > seems to be the cleanest thing. > As I said, because v can be a const pointer provided by the caller. Try it yourself and you'll discover hundred of call sites doing .... some_function(const struct *xxx, ...) { if (atomic_read(&xxx->refcnt) <= 0) do_something(); else do_otherthing(); } > And if you don't think this is "an option", I really can't see why you > care about the extra instructions in the code stream either. > Not an option if we have to change all callers that expected to be able to use a const atomic_t pointer. OK, I now have to leave the net.