From: Paul Jackson <pj@sgi.com>
To: Paul Jackson <pj@sgi.com>
Cc: colpatch@us.ibm.com, wli@holomorphy.com, linux-kernel@vger.kernel.org
Subject: [Patch 11/23] mask v2 - Add new nodemasks.h file
Date: Thu, 1 Apr 2004 13:12:07 -0800 [thread overview]
Message-ID: <20040401131207.37fe8bdc.pj@sgi.com> (raw)
In-Reply-To: <20040401122802.23521599.pj@sgi.com>
Patch_11_of_23 - Add new nodemasks.h file.
Provide a nodemasks_t type, using the mask.h ADT.
Diffstat Patch_11_of_23:
nodemask.h | 152 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 152 insertions(+)
===================================================================
--- 2.6.4.orig/include/linux/nodemask.h 1969-12-31 16:00:00.000000000 -0800
+++ 2.6.4/include/linux/nodemask.h 2004-04-01 09:42:21.000000000 -0800
@@ -0,0 +1,156 @@
+#ifndef __LINUX_NODEMASK_H
+#define __LINUX_NODEMASK_H
+
+/*
+ * Nodemasks provide a bit mask suitable for representing the
+ * set of Node's in a system, one bit position per Node number.
+ *
+ * See detailed comments in the file linux/mask.h describing the
+ * data type on which these nodemasks are based.
+ *
+ * For details of nodemask_scnprintf() and nodemask_parse(),
+ * see bitmap_scnprintf() and bitmap_parse() in lib/bitmap.c.
+ *
+ * The available nodemask operations are:
+ *
+ * void node_set(node, mask) turn on bit 'node' in mask
+ * void node_clear(node, mask) turn off bit 'node' in mask
+ * void nodes_setall(mask) set all bits
+ * void nodes_clear(mask) clear all bits
+ * int node_isset(node, mask) true iff bit 'node' set in mask
+ * int node_test_and_set(node, mask) test and set bit 'node' in mask
+ *
+ * void nodes_and(dst, src1, src2) dst = src1 & src2 [intersection]
+ * void nodes_or(dst, src1, src2) dst = src1 | src2 [union]
+ * void nodes_xor(dst, src1, src2) dst = src1 ^ src2
+ * void nodes_andnot(dst, src1, src2) dst = src1 & ~src2
+ * void nodes_complement(dst, src) dst = ~src
+ *
+ * int nodes_equal(mask1, mask2) Does mask1 == mask2?
+ * int nodes_intersects(mask1, mask2) Do mask1 and mask2 intersect?
+ * int nodes_subset(mask1, mask2) Is mask1 a subset of mask2?
+ * int nodes_empty(mask) Is mask empty (no bits sets)?
+ * int nodes_full(mask) Is mask full (all bits sets)?
+ * int nodes_weight(mask) Hamming weigh - number of set bits
+ *
+ * void nodes_shift_right(dst, src, n) Shift right
+ * void nodes_shift_left(dst, src, n) Shift left
+ *
+ * int first_node(mask) Number lowest set bit, or MAX_NUMNODES
+ * int next_node(node, mask) Next node past 'node', or MAX_NUMNODES
+ *
+ * nodemask_t nodemask_of_node(node) Return nodemask with bit 'node' set
+ * NODE_MASK_ALL Initializer - all bits set
+ * NODE_MASK_NONE Initializer - no bits set
+ * unsigned long *nodes_addr(mask) Array of unsigned long's in mask
+ *
+ * int nodemask_scnprintf(buf, len, mask) Format nodemask for printing
+ * int nodemask_parse(ubuf, ulen, mask) Parse ascii string as nodemask
+ *
+ * int num_online_nodes() Number of online nodes
+ * int num_possible_nodes() Number of all possible nodes
+ * int node_online(node) Is some node < MAX_NUMNODES online?
+ * int node_possible(node) Is some node < MAX_NUMNODES possible?
+ * void node_set_online(node) set node in node_online_map
+ * void node_set_offline(node) clear node in node_online_map
+ * int any_online_node(mask) First online node in mask
+ *
+ * for_each_node_mask(node, mask) for-loop node over mask
+ * for_each_node(node) for-loop node over node_possible_map
+ * for_each_online_node(node) for-loop node over node_online_map
+ */
+
+#include <linux/numa.h>
+#include <linux/mask.h>
+#include <asm/bug.h>
+
+typedef __mask(MAX_NUMNODES) nodemask_t;
+extern nodemask_t _unused_nodemask_arg_;
+
+#define node_set(node, mask) mask_setbit((node), (mask))
+#define node_clear(node, mask) mask_clearbit((node), (mask))
+#define nodes_setall(mask) mask_setall((mask), MAX_NUMNODES)
+#define nodes_clear(mask) mask_clearall((mask), MAX_NUMNODES)
+#define node_isset(node, mask) mask_isset((node), (mask))
+#define node_test_and_set(node, mask) mask_test_and_set((node), (mask))
+#define nodes_and(dst, src1, src2) mask_and((dst), (src1), (src2), MAX_NUMNODES)
+#define nodes_or(dst, src1, src2) mask_or((dst), (src1), (src2), MAX_NUMNODES)
+#define nodes_xor(dst, src1, src2) mask_xor((dst), (src1), (src2), MAX_NUMNODES)
+#define nodes_andnot(dst, src1, src2) mask_andnot((dst), (src1), (src2), MAX_NUMNODES)
+#define nodes_complement(dst, src) mask_complement((dst), (src), MAX_NUMNODES)
+#define nodes_equal(mask1, mask2) mask_equal((mask1), (mask2), MAX_NUMNODES)
+#define nodes_intersects(mask1, mask2) mask_intersects((mask1), (mask2), MAX_NUMNODES)
+#define nodes_subset(mask1, mask2) mask_subset((mask1), (mask2), MAX_NUMNODES)
+#define nodes_empty(mask) mask_empty((mask), MAX_NUMNODES)
+#define nodes_full(mask) mask_full((mask), MAX_NUMNODES)
+#define nodes_weight(mask) mask_weight((mask), MAX_NUMNODES)
+#define nodes_shift_right(dst, src, n) \
+ mask_shift_right((dst), (src), (n), MAX_NUMNODES)
+#define nodes_shift_left(dst, src, n) \
+ mask_shift_left((dst), (src), (n), MAX_NUMNODES)
+#define first_node(mask) mask_first((mask), MAX_NUMNODES)
+#define next_node(node, mask) mask_next((node), (mask), MAX_NUMNODES)
+#define nodemask_of_node(node) \
+ mask_of_bit((node), _unused_nodemask_arg_)
+#if MAX_NUMNODES <= BITS_PER_LONG
+#define NODE_MASK_ALL MASK_ALL1(MAX_NUMNODES)
+#else
+#define NODE_MASK_ALL MASK_ALL2(MAX_NUMNODES)
+#endif
+#define NODE_MASK_NONE MASK_NONE(MAX_NUMNODES)
+#define nodes_addr(mask) mask_addr(mask)
+#define nodemask_scnprintf(buf, len, mask) \
+ mask_scnprintf((buf), (len), (mask), MAX_NUMNODES)
+#define nodemask_parse(ubuf, ulen, mask) \
+ mask_parse((ubuf), (ulen), (mask), MAX_NUMNODES)
+
+/*
+ * The following particular system nodemasks and operations
+ * on them manage all (possible) and online nodes.
+ */
+
+extern nodemask_t node_online_map;
+extern nodemask_t node_possible_map;
+
+#ifdef CONFIG_NUMA
+
+#define num_online_nodes() nodes_weight(node_online_map)
+#define num_possible_nodes() nodes_weight(node_possible_map)
+#define node_online(node) node_isset((node), node_online_map)
+#define node_possible(node) node_isset((node), node_possible_map)
+#define node_set_online(node) node_set((node), node_online_map)
+#define node_set_offline(node) node_clear((node), node_online_map)
+
+#define any_online_node(mask) \
+({ \
+ nodemask_t n; \
+ nodes_and(n, mask, node_online_map); \
+ first_node(n); \
+})
+
+#define for_each_node_mask(node, mask) \
+ for (node = first_node(mask); \
+ node < MAX_NUMNODES; \
+ node = next_node(node, mask))
+
+#else /* !CONFIG_NUMA */
+
+#define num_online_nodes() 1
+#define num_possible_nodes() 1
+#define node_online(node) ({ BUG_ON((node) != 0); 1; })
+#define node_possible(node) ({ BUG_ON((node) != 0); 1; })
+#define node_set_online(node) ({ BUG_ON((node) != 0); })
+#define node_set_offline(node) ({ BUG(); })
+
+#define any_online_node(mask) 0
+
+#define for_each_node_mask(node, mask) for (node = 0; node < 1; node++)
+
+#endif /* CONFIG_NUMA */
+
+#define for_each_node(node) \
+ for_each_node_mask(node, node_possible_map)
+#define for_each_online_node(node) \
+ for_each_node_mask(node, node_online_map)
+
+#endif /* __LINUX_NODEMASK_H */
--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj@sgi.com> 1.650.933.1373
next prev parent reply other threads:[~2004-04-01 21:17 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-01 20:28 [Patch 0/23] mask v2 - Second version of mask, cpumask and nodemask consolidation Paul Jackson
2004-04-01 21:10 ` [Patch 1/23] mask v2 - Document bitmap.c bit model Paul Jackson
2004-04-01 21:10 ` [Patch 2/23] mask v2 - Tighten unused bitmap bit handling Paul Jackson
2004-04-01 21:11 ` [Patch 3/23] mask v2 - New bitmap operators Paul Jackson
2004-04-01 21:11 ` [Patch 4/23] mask v2 - two missing 'const' qualifiers Paul Jackson
2004-04-01 21:11 ` [Patch 5/23] mask v2 - Add new mask.h file Paul Jackson
2004-04-02 20:26 ` Matthew Dobson
2004-04-03 5:12 ` Paul Jackson
2004-04-01 21:11 ` [Patch 6/23] mask v2 - Replace cpumask_t with one using mask Paul Jackson
2004-04-02 22:24 ` Matthew Dobson
2004-04-02 23:35 ` Paul Jackson
2004-04-03 1:09 ` Matthew Dobson
2004-04-03 6:00 ` Paul Jackson
2004-04-04 5:57 ` Paul Jackson
2004-04-03 5:23 ` Paul Jackson
2004-04-01 21:11 ` [Patch 7/23] mask v2 - Remove i386 obsolete cpumask ops Paul Jackson
2004-04-01 21:11 ` [Patch 8/23] mask v2 - Remove ppc64 " Paul Jackson
2004-04-01 21:11 ` [Patch 9/23] mask v2 - Remove x86_64 " Paul Jackson
2004-04-01 21:12 ` [Patch 10/23] mask v2 - Remove obsolete cpumask emulation Paul Jackson
2004-04-01 21:12 ` Paul Jackson [this message]
2004-04-01 21:12 ` [Patch 12/23] mask v2 - [1/7] mmzone.h changes for nodemask Paul Jackson
2004-04-01 21:12 ` [Patch 13/23] mask v2 - [2/7] nodemask_t core changes Paul Jackson
2004-04-01 21:12 ` [Patch 14/23] mask v2 - [3/7] nodemask_t_i386_changes Paul Jackson
2004-04-01 21:12 ` [Patch 15/23] mask v2 - [4/7] nodemask_t_pp64_changes Paul Jackson
2004-04-01 21:12 ` [Patch 16/23] mask v2 - [5/7] nodemask_t_x86_64_changes Paul Jackson
2004-04-01 21:12 ` [Patch 17/23] mask v2 = [6/7] nodemask_t_ia64_changes Paul Jackson
2004-04-06 11:37 ` Paul Jackson
2004-04-07 5:55 ` Denis Vlasenko
2004-04-07 6:50 ` Paul Jackson
2004-04-07 7:44 ` Paul Jackson
2004-04-07 14:13 ` Nick Piggin
2004-04-07 14:44 ` Paul Jackson
2004-04-07 15:02 ` Nick Piggin
2004-04-07 15:21 ` Paul Jackson
2004-04-09 7:54 ` Denis Vlasenko
2004-04-09 17:53 ` Paul Jackson
2004-04-09 20:04 ` Denis Vlasenko
2004-04-10 2:54 ` Paul Jackson
2004-04-07 11:27 ` Paul Jackson
2004-04-09 18:54 ` Paul Jackson
2004-04-01 21:12 ` [Patch 18/23] mask v2 - [7/7] nodemask_t_other_arch_changes Paul Jackson
2004-04-01 21:12 ` [Patch 19/23] mask v2 - Simplify sparc64 cpumask loop code Paul Jackson
2004-04-01 21:12 ` [Patch 20/23] mask v2 - Optimize i386 cpumask macro usage Paul Jackson
2004-04-01 21:13 ` [Patch 21/23] mask v2 - Dyadic physids_complement() Paul Jackson
2004-04-01 21:13 ` [Patch 22/23] mask v2 - Fix cpumask in asm-x86_64/topology.h Paul Jackson
2004-04-01 21:13 ` [Patch 23/23] mask v2 - Cpumask tweak in kernel/sched.c Paul Jackson
2004-04-02 8:15 ` [Patch 24/23] mask v2 - Small system optimizations Paul Jackson
2004-04-04 5:56 ` Paul Jackson
2004-04-04 6:16 ` [Patch 24a/23] mask v2 - UP fix, faster mask_of_bit, MASK_ALL* names Paul Jackson
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=20040401131207.37fe8bdc.pj@sgi.com \
--to=pj@sgi.com \
--cc=colpatch@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=wli@holomorphy.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).