All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nick Bowler <nbowler@elliptictech.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Lin Ming <ming.m.lin@intel.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org,
	linux-arch@vger.kernel.org
Subject: Re: [PATCH 1/2] mm: convert k{un}map_atomic(p, KM_type) to k{un}map_atomic(p)
Date: Fri, 26 Aug 2011 16:40:53 -0400	[thread overview]
Message-ID: <20110826204053.GA3408@elliptictech.com> (raw)
In-Reply-To: <20110826124239.fc503491.akpm@linux-foundation.org>

On 2011-08-26 12:42 -0700, Andrew Morton wrote:
> On Fri, 26 Aug 2011 10:58:16 +0200
> Peter Zijlstra <peterz@infradead.org> wrote:
> > On Fri, 2011-08-26 at 16:17 +0800, Lin Ming wrote:
> > > 
> > > The KM_type parameter for kmap_atomic/kunmap_atomic is not used
> > > anymore since commit 3e4d3af(mm: stack based kmap_atomic()).
[...]
> > yet-another-massive patch.. (you're the third or fourth to do so) if
> > Andrew wants to take this one I won't mind, however previously he
> > didn't want flag day patches..
> 
> I'm OK with cleaning all these up, but I suggest that we leave the
> back-compatibility macros in place for a while, to make sure that
> various stragglers get converted.  Extra marks will be awarded for
> working out how to make unconverted code generate a compile warning ;)

It's possible to (ab)use the C preprocessor to accomplish this sort of
thing.  For instance, consider the following:

  #include <stdio.h>

  int foo(int x)
  {
     return x;
  }

  /* Deprecated; call foo instead. */
  static inline int __attribute__((deprecated)) foo_unconverted(int x, int unused)
  {
     return foo(x);
  }

  #define PASTE(a, b) a ## b
  #define PASTE2(a, b) PASTE(a, b)
  
  #define NARG_(_9, _8, _7, _6, _5, _4, _3, _2, _1, n, ...) n
  #define NARG(...) NARG_(__VA_ARGS__, 9, 8, 7, 6, 5, 4, 3, 2, 1, :)

  #define foo1(...) foo(__VA_ARGS__)
  #define foo2(...) foo_unconverted(__VA_ARGS__)
  #define foo(...) PASTE2(foo, NARG(__VA_ARGS__)(__VA_ARGS__))

  int main(void)
  {
    printf("%d\n", foo(42));
    printf("%d\n", foo(54, 42));
    return 0;
  }

The preprocessor will select between "foo" and "foo_unconverted"
depending on the number of arguments passed; and gcc will emit a warning
for the latter case:

  % gcc test.c
  test.c: In function ‘main’:
  test.c:27: warning: ‘foo_unconverted’ is deprecated (declared at test.c:9)

Cheers,
-- 
Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)

WARNING: multiple messages have this Message-ID (diff)
From: Nick Bowler <nbowler@elliptictech.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Lin Ming <ming.m.lin@intel.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org,
	linux-arch@vger.kernel.org
Subject: Re: [PATCH 1/2] mm: convert k{un}map_atomic(p, KM_type) to k{un}map_atomic(p)
Date: Fri, 26 Aug 2011 16:40:53 -0400	[thread overview]
Message-ID: <20110826204053.GA3408@elliptictech.com> (raw)
In-Reply-To: <20110826124239.fc503491.akpm@linux-foundation.org>

On 2011-08-26 12:42 -0700, Andrew Morton wrote:
> On Fri, 26 Aug 2011 10:58:16 +0200
> Peter Zijlstra <peterz@infradead.org> wrote:
> > On Fri, 2011-08-26 at 16:17 +0800, Lin Ming wrote:
> > > 
> > > The KM_type parameter for kmap_atomic/kunmap_atomic is not used
> > > anymore since commit 3e4d3af(mm: stack based kmap_atomic()).
[...]
> > yet-another-massive patch.. (you're the third or fourth to do so) if
> > Andrew wants to take this one I won't mind, however previously he
> > didn't want flag day patches..
> 
> I'm OK with cleaning all these up, but I suggest that we leave the
> back-compatibility macros in place for a while, to make sure that
> various stragglers get converted.  Extra marks will be awarded for
> working out how to make unconverted code generate a compile warning ;)

It's possible to (ab)use the C preprocessor to accomplish this sort of
thing.  For instance, consider the following:

  #include <stdio.h>

  int foo(int x)
  {
     return x;
  }

  /* Deprecated; call foo instead. */
  static inline int __attribute__((deprecated)) foo_unconverted(int x, int unused)
  {
     return foo(x);
  }

  #define PASTE(a, b) a ## b
  #define PASTE2(a, b) PASTE(a, b)
  
  #define NARG_(_9, _8, _7, _6, _5, _4, _3, _2, _1, n, ...) n
  #define NARG(...) NARG_(__VA_ARGS__, 9, 8, 7, 6, 5, 4, 3, 2, 1, :)

  #define foo1(...) foo(__VA_ARGS__)
  #define foo2(...) foo_unconverted(__VA_ARGS__)
  #define foo(...) PASTE2(foo, NARG(__VA_ARGS__)(__VA_ARGS__))

  int main(void)
  {
    printf("%d\n", foo(42));
    printf("%d\n", foo(54, 42));
    return 0;
  }

The preprocessor will select between "foo" and "foo_unconverted"
depending on the number of arguments passed; and gcc will emit a warning
for the latter case:

  % gcc test.c
  test.c: In function a??maina??:
  test.c:27: warning: a??foo_unconverteda?? is deprecated (declared at test.c:9)

Cheers,
-- 
Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2011-08-26 20:41 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-26  8:17 [PATCH 1/2] mm: convert k{un}map_atomic(p, KM_type) to k{un}map_atomic(p) Lin Ming
2011-08-26  8:17 ` Lin Ming
2011-08-26  8:58 ` Peter Zijlstra
2011-08-26  8:58   ` Peter Zijlstra
2011-08-26 19:42   ` Andrew Morton
2011-08-26 19:42     ` Andrew Morton
2011-08-26 20:40     ` Nick Bowler [this message]
2011-08-26 20:40       ` Nick Bowler
2011-08-29 12:33       ` Peter Zijlstra
2011-08-29 12:33         ` Peter Zijlstra
2011-08-29 12:27     ` Peter Zijlstra
2011-08-29 12:27       ` Peter Zijlstra
2011-08-29 12:27       ` [Drbd-dev] " Peter Zijlstra
2011-08-29 12:27       ` Peter Zijlstra
2011-08-26  8:59 ` Peter Zijlstra
2011-08-26  8:59   ` Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110826204053.GA3408@elliptictech.com \
    --to=nbowler@elliptictech.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ming.m.lin@intel.com \
    --cc=peterz@infradead.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.