diff options
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/cgroups/cgroups.txt | 9 | ||||
-rw-r--r-- | Documentation/controllers/memcg_test.txt | 342 | ||||
-rw-r--r-- | Documentation/controllers/memory.txt | 135 | ||||
-rw-r--r-- | Documentation/hwmon/abituguru-datasheet | 4 | ||||
-rw-r--r-- | Documentation/kernel-parameters.txt | 3 | ||||
-rw-r--r-- | Documentation/powerpc/dts-bindings/fsl/board.txt | 32 | ||||
-rw-r--r-- | Documentation/scsi/scsi_fc_transport.txt | 4 | ||||
-rw-r--r-- | Documentation/w1/masters/00-INDEX | 2 | ||||
-rw-r--r-- | Documentation/w1/masters/mxc-w1 | 11 | ||||
-rw-r--r-- | Documentation/w1/w1.netlink | 164 |
10 files changed, 649 insertions, 57 deletions
diff --git a/Documentation/cgroups/cgroups.txt b/Documentation/cgroups/cgroups.txt index d9014aa0eb68..e33ee74eee77 100644 --- a/Documentation/cgroups/cgroups.txt +++ b/Documentation/cgroups/cgroups.txt | |||
@@ -227,7 +227,6 @@ Each cgroup is represented by a directory in the cgroup file system | |||
227 | containing the following files describing that cgroup: | 227 | containing the following files describing that cgroup: |
228 | 228 | ||
229 | - tasks: list of tasks (by pid) attached to that cgroup | 229 | - tasks: list of tasks (by pid) attached to that cgroup |
230 | - releasable flag: cgroup currently removeable? | ||
231 | - notify_on_release flag: run the release agent on exit? | 230 | - notify_on_release flag: run the release agent on exit? |
232 | - release_agent: the path to use for release notifications (this file | 231 | - release_agent: the path to use for release notifications (this file |
233 | exists in the top cgroup only) | 232 | exists in the top cgroup only) |
@@ -360,7 +359,7 @@ Now you want to do something with this cgroup. | |||
360 | 359 | ||
361 | In this directory you can find several files: | 360 | In this directory you can find several files: |
362 | # ls | 361 | # ls |
363 | notify_on_release releasable tasks | 362 | notify_on_release tasks |
364 | (plus whatever files added by the attached subsystems) | 363 | (plus whatever files added by the attached subsystems) |
365 | 364 | ||
366 | Now attach your shell to this cgroup: | 365 | Now attach your shell to this cgroup: |
@@ -479,7 +478,6 @@ newly-created cgroup if an error occurs after this subsystem's | |||
479 | create() method has been called for the new cgroup). | 478 | create() method has been called for the new cgroup). |
480 | 479 | ||
481 | void pre_destroy(struct cgroup_subsys *ss, struct cgroup *cgrp); | 480 | void pre_destroy(struct cgroup_subsys *ss, struct cgroup *cgrp); |
482 | (cgroup_mutex held by caller) | ||
483 | 481 | ||
484 | Called before checking the reference count on each subsystem. This may | 482 | Called before checking the reference count on each subsystem. This may |
485 | be useful for subsystems which have some extra references even if | 483 | be useful for subsystems which have some extra references even if |
@@ -498,6 +496,7 @@ remain valid while the caller holds cgroup_mutex. | |||
498 | 496 | ||
499 | void attach(struct cgroup_subsys *ss, struct cgroup *cgrp, | 497 | void attach(struct cgroup_subsys *ss, struct cgroup *cgrp, |
500 | struct cgroup *old_cgrp, struct task_struct *task) | 498 | struct cgroup *old_cgrp, struct task_struct *task) |
499 | (cgroup_mutex held by caller) | ||
501 | 500 | ||
502 | Called after the task has been attached to the cgroup, to allow any | 501 | Called after the task has been attached to the cgroup, to allow any |
503 | post-attachment activity that requires memory allocations or blocking. | 502 | post-attachment activity that requires memory allocations or blocking. |
@@ -511,6 +510,7 @@ void exit(struct cgroup_subsys *ss, struct task_struct *task) | |||
511 | Called during task exit. | 510 | Called during task exit. |
512 | 511 | ||
513 | int populate(struct cgroup_subsys *ss, struct cgroup *cgrp) | 512 | int populate(struct cgroup_subsys *ss, struct cgroup *cgrp) |
513 | (cgroup_mutex held by caller) | ||
514 | 514 | ||
515 | Called after creation of a cgroup to allow a subsystem to populate | 515 | Called after creation of a cgroup to allow a subsystem to populate |
516 | the cgroup directory with file entries. The subsystem should make | 516 | the cgroup directory with file entries. The subsystem should make |
@@ -520,6 +520,7 @@ method can return an error code, the error code is currently not | |||
520 | always handled well. | 520 | always handled well. |
521 | 521 | ||
522 | void post_clone(struct cgroup_subsys *ss, struct cgroup *cgrp) | 522 | void post_clone(struct cgroup_subsys *ss, struct cgroup *cgrp) |
523 | (cgroup_mutex held by caller) | ||
523 | 524 | ||
524 | Called at the end of cgroup_clone() to do any paramater | 525 | Called at the end of cgroup_clone() to do any paramater |
525 | initialization which might be required before a task could attach. For | 526 | initialization which might be required before a task could attach. For |
@@ -527,7 +528,7 @@ example in cpusets, no task may attach before 'cpus' and 'mems' are set | |||
527 | up. | 528 | up. |
528 | 529 | ||
529 | void bind(struct cgroup_subsys *ss, struct cgroup *root) | 530 | void bind(struct cgroup_subsys *ss, struct cgroup *root) |
530 | (cgroup_mutex held by caller) | 531 | (cgroup_mutex and ss->hierarchy_mutex held by caller) |
531 | 532 | ||
532 | Called when a cgroup subsystem is rebound to a different hierarchy | 533 | Called when a cgroup subsystem is rebound to a different hierarchy |
533 | and root cgroup. Currently this will only involve movement between | 534 | and root cgroup. Currently this will only involve movement between |
diff --git a/Documentation/controllers/memcg_test.txt b/Documentation/controllers/memcg_test.txt new file mode 100644 index 000000000000..08d4d3ea0d79 --- /dev/null +++ b/Documentation/controllers/memcg_test.txt | |||
@@ -0,0 +1,342 @@ | |||
1 | Memory Resource Controller(Memcg) Implementation Memo. | ||
2 | Last Updated: 2008/12/15 | ||
3 | Base Kernel Version: based on 2.6.28-rc8-mm. | ||
4 | |||
5 | Because VM is getting complex (one of reasons is memcg...), memcg's behavior | ||
6 | is complex. This is a document for memcg's internal behavior. | ||
7 | Please note that implementation details can be changed. | ||
8 | |||
9 | (*) Topics on API should be in Documentation/controllers/memory.txt) | ||
10 | |||
11 | 0. How to record usage ? | ||
12 | 2 objects are used. | ||
13 | |||
14 | page_cgroup ....an object per page. | ||
15 | Allocated at boot or memory hotplug. Freed at memory hot removal. | ||
16 | |||
17 | swap_cgroup ... an entry per swp_entry. | ||
18 | Allocated at swapon(). Freed at swapoff(). | ||
19 | |||
20 | The page_cgroup has USED bit and double count against a page_cgroup never | ||
21 | occurs. swap_cgroup is used only when a charged page is swapped-out. | ||
22 | |||
23 | 1. Charge | ||
24 | |||
25 | a page/swp_entry may be charged (usage += PAGE_SIZE) at | ||
26 | |||
27 | mem_cgroup_newpage_charge() | ||
28 | Called at new page fault and Copy-On-Write. | ||
29 | |||
30 | mem_cgroup_try_charge_swapin() | ||
31 | Called at do_swap_page() (page fault on swap entry) and swapoff. | ||
32 | Followed by charge-commit-cancel protocol. (With swap accounting) | ||
33 | At commit, a charge recorded in swap_cgroup is removed. | ||
34 | |||
35 | mem_cgroup_cache_charge() | ||
36 | Called at add_to_page_cache() | ||
37 | |||
38 | mem_cgroup_cache_charge_swapin() | ||
39 | Called at shmem's swapin. | ||
40 | |||
41 | mem_cgroup_prepare_migration() | ||
42 | Called before migration. "extra" charge is done and followed by | ||
43 | charge-commit-cancel protocol. | ||
44 | At commit, charge against oldpage or newpage will be committed. | ||
45 | |||
46 | 2. Uncharge | ||
47 | a page/swp_entry may be uncharged (usage -= PAGE_SIZE) by | ||
48 | |||
49 | mem_cgroup_uncharge_page() | ||
50 | Called when an anonymous page is fully unmapped. I.e., mapcount goes | ||
51 | to 0. If the page is SwapCache, uncharge is delayed until | ||
52 | mem_cgroup_uncharge_swapcache(). | ||
53 | |||
54 | mem_cgroup_uncharge_cache_page() | ||
55 | Called when a page-cache is deleted from radix-tree. If the page is | ||
56 | SwapCache, uncharge is delayed until mem_cgroup_uncharge_swapcache(). | ||
57 | |||
58 | mem_cgroup_uncharge_swapcache() | ||
59 | Called when SwapCache is removed from radix-tree. The charge itself | ||
60 | is moved to swap_cgroup. (If mem+swap controller is disabled, no | ||
61 | charge to swap occurs.) | ||
62 | |||
63 | mem_cgroup_uncharge_swap() | ||
64 | Called when swp_entry's refcnt goes down to 0. A charge against swap | ||
65 | disappears. | ||
66 | |||
67 | mem_cgroup_end_migration(old, new) | ||
68 | At success of migration old is uncharged (if necessary), a charge | ||
69 | to new page is committed. At failure, charge to old page is committed. | ||
70 | |||
71 | 3. charge-commit-cancel | ||
72 | In some case, we can't know this "charge" is valid or not at charging | ||
73 | (because of races). | ||
74 | To handle such case, there are charge-commit-cancel functions. | ||
75 | mem_cgroup_try_charge_XXX | ||
76 | mem_cgroup_commit_charge_XXX | ||
77 | mem_cgroup_cancel_charge_XXX | ||
78 | these are used in swap-in and migration. | ||
79 | |||
80 | At try_charge(), there are no flags to say "this page is charged". | ||
81 | at this point, usage += PAGE_SIZE. | ||
82 | |||
83 | At commit(), the function checks the page should be charged or not | ||
84 | and set flags or avoid charging.(usage -= PAGE_SIZE) | ||
85 | |||
86 | At cancel(), simply usage -= PAGE_SIZE. | ||
87 | |||
88 | Under below explanation, we assume CONFIG_MEM_RES_CTRL_SWAP=y. | ||
89 | |||
90 | 4. Anonymous | ||
91 | Anonymous page is newly allocated at | ||
92 | - page fault into MAP_ANONYMOUS mapping. | ||
93 | - Copy-On-Write. | ||
94 | It is charged right after it's allocated before doing any page table | ||
95 | related operations. Of course, it's uncharged when another page is used | ||
96 | for the fault address. | ||
97 | |||
98 | At freeing anonymous page (by exit() or munmap()), zap_pte() is called | ||
99 | and pages for ptes are freed one by one.(see mm/memory.c). Uncharges | ||
100 | are done at page_remove_rmap() when page_mapcount() goes down to 0. | ||
101 | |||
102 | Another page freeing is by page-reclaim (vmscan.c) and anonymous | ||
103 | pages are swapped out. In this case, the page is marked as | ||
104 | PageSwapCache(). uncharge() routine doesn't uncharge the page marked | ||
105 | as SwapCache(). It's delayed until __delete_from_swap_cache(). | ||
106 | |||
107 | 4.1 Swap-in. | ||
108 | At swap-in, the page is taken from swap-cache. There are 2 cases. | ||
109 | |||
110 | (a) If the SwapCache is newly allocated and read, it has no charges. | ||
111 | (b) If the SwapCache has been mapped by processes, it has been | ||
112 | charged already. | ||
113 | |||
114 | This swap-in is one of the most complicated work. In do_swap_page(), | ||
115 | following events occur when pte is unchanged. | ||
116 | |||
117 | (1) the page (SwapCache) is looked up. | ||
118 | (2) lock_page() | ||
119 | (3) try_charge_swapin() | ||
120 | (4) reuse_swap_page() (may call delete_swap_cache()) | ||
121 | (5) commit_charge_swapin() | ||
122 | (6) swap_free(). | ||
123 | |||
124 | Considering following situation for example. | ||
125 | |||
126 | (A) The page has not been charged before (2) and reuse_swap_page() | ||
127 | doesn't call delete_from_swap_cache(). | ||
128 | (B) The page has not been charged before (2) and reuse_swap_page() | ||
129 | calls delete_from_swap_cache(). | ||
130 | (C) The page has been charged before (2) and reuse_swap_page() doesn't | ||
131 | call delete_from_swap_cache(). | ||
132 | (D) The page has been charged before (2) and reuse_swap_page() calls | ||
133 | delete_from_swap_cache(). | ||
134 | |||
135 | memory.usage/memsw.usage changes to this page/swp_entry will be | ||
136 | Case (A) (B) (C) (D) | ||
137 | Event | ||
138 | Before (2) 0/ 1 0/ 1 1/ 1 1/ 1 | ||
139 | =========================================== | ||
140 | (3) +1/+1 +1/+1 +1/+1 +1/+1 | ||
141 | (4) - 0/ 0 - -1/ 0 | ||
142 | (5) 0/-1 0/ 0 -1/-1 0/ 0 | ||
143 | (6) - 0/-1 - 0/-1 | ||
144 | =========================================== | ||
145 | Result 1/ 1 1/ 1 1/ 1 1/ 1 | ||
146 | |||
147 | In any cases, charges to this page should be 1/ 1. | ||
148 | |||
149 | 4.2 Swap-out. | ||
150 | At swap-out, typical state transition is below. | ||
151 | |||
152 | (a) add to swap cache. (marked as SwapCache) | ||
153 | swp_entry's refcnt += 1. | ||
154 | (b) fully unmapped. | ||
155 | swp_entry's refcnt += # of ptes. | ||
156 | (c) write back to swap. | ||
157 | (d) delete from swap cache. (remove from SwapCache) | ||
158 | swp_entry's refcnt -= 1. | ||
159 | |||
160 | |||
161 | At (b), the page is marked as SwapCache and not uncharged. | ||
162 | At (d), the page is removed from SwapCache and a charge in page_cgroup | ||
163 | is moved to swap_cgroup. | ||
164 | |||
165 | Finally, at task exit, | ||
166 | (e) zap_pte() is called and swp_entry's refcnt -=1 -> 0. | ||
167 | Here, a charge in swap_cgroup disappears. | ||
168 | |||
169 | 5. Page Cache | ||
170 | Page Cache is charged at | ||
171 | - add_to_page_cache_locked(). | ||
172 | |||
173 | uncharged at | ||
174 | - __remove_from_page_cache(). | ||
175 | |||
176 | The logic is very clear. (About migration, see below) | ||
177 | Note: __remove_from_page_cache() is called by remove_from_page_cache() | ||
178 | and __remove_mapping(). | ||
179 | |||
180 | 6. Shmem(tmpfs) Page Cache | ||
181 | Memcg's charge/uncharge have special handlers of shmem. The best way | ||
182 | to understand shmem's page state transition is to read mm/shmem.c. | ||
183 | But brief explanation of the behavior of memcg around shmem will be | ||
184 | helpful to understand the logic. | ||
185 | |||
186 | Shmem's page (just leaf page, not direct/indirect block) can be on | ||
187 | - radix-tree of shmem's inode. | ||
188 | - SwapCache. | ||
189 | - Both on radix-tree and SwapCache. This happens at swap-in | ||
190 | and swap-out, | ||
191 | |||
192 | It's charged when... | ||
193 | - A new page is added to shmem's radix-tree. | ||
194 | - A swp page is read. (move a charge from swap_cgroup to page_cgroup) | ||
195 | It's uncharged when | ||
196 | - A page is removed from radix-tree and not SwapCache. | ||
197 | - When SwapCache is removed, a charge is moved to swap_cgroup. | ||
198 | - When swp_entry's refcnt goes down to 0, a charge in swap_cgroup | ||
199 | disappears. | ||
200 | |||
201 | 7. Page Migration | ||
202 | One of the most complicated functions is page-migration-handler. | ||
203 | Memcg has 2 routines. Assume that we are migrating a page's contents | ||
204 | from OLDPAGE to NEWPAGE. | ||
205 | |||
206 | Usual migration logic is.. | ||
207 | (a) remove the page from LRU. | ||
208 | (b) allocate NEWPAGE (migration target) | ||
209 | (c) lock by lock_page(). | ||
210 | (d) unmap all mappings. | ||
211 | (e-1) If necessary, replace entry in radix-tree. | ||
212 | (e-2) move contents of a page. | ||
213 | (f) map all mappings again. | ||
214 | (g) pushback the page to LRU. | ||
215 | (-) OLDPAGE will be freed. | ||
216 | |||
217 | Before (g), memcg should complete all necessary charge/uncharge to | ||
218 | NEWPAGE/OLDPAGE. | ||
219 | |||
220 | The point is.... | ||
221 | - If OLDPAGE is anonymous, all charges will be dropped at (d) because | ||
222 | try_to_unmap() drops all mapcount and the page will not be | ||
223 | SwapCache. | ||
224 | |||
225 | - If OLDPAGE is SwapCache, charges will be kept at (g) because | ||
226 | __delete_from_swap_cache() isn't called at (e-1) | ||
227 | |||
228 | - If OLDPAGE is page-cache, charges will be kept at (g) because | ||
229 | remove_from_swap_cache() isn't called at (e-1) | ||
230 | |||
231 | memcg provides following hooks. | ||
232 | |||
233 | - mem_cgroup_prepare_migration(OLDPAGE) | ||
234 | Called after (b) to account a charge (usage += PAGE_SIZE) against | ||
235 | memcg which OLDPAGE belongs to. | ||
236 | |||
237 | - mem_cgroup_end_migration(OLDPAGE, NEWPAGE) | ||
238 | Called after (f) before (g). | ||
239 | If OLDPAGE is used, commit OLDPAGE again. If OLDPAGE is already | ||
240 | charged, a charge by prepare_migration() is automatically canceled. | ||
241 | If NEWPAGE is used, commit NEWPAGE and uncharge OLDPAGE. | ||
242 | |||
243 | But zap_pte() (by exit or munmap) can be called while migration, | ||
244 | we have to check if OLDPAGE/NEWPAGE is a valid page after commit(). | ||
245 | |||
246 | 8. LRU | ||
247 | Each memcg has its own private LRU. Now, it's handling is under global | ||
248 | VM's control (means that it's handled under global zone->lru_lock). | ||
249 | Almost all routines around memcg's LRU is called by global LRU's | ||
250 | list management functions under zone->lru_lock(). | ||
251 | |||
252 | A special function is mem_cgroup_isolate_pages(). This scans | ||
253 | memcg's private LRU and call __isolate_lru_page() to extract a page | ||
254 | from LRU. | ||
255 | (By __isolate_lru_page(), the page is removed from both of global and | ||
256 | private LRU.) | ||
257 | |||
258 | |||
259 | 9. Typical Tests. | ||
260 | |||
261 | Tests for racy cases. | ||
262 | |||
263 | 9.1 Small limit to memcg. | ||
264 | When you do test to do racy case, it's good test to set memcg's limit | ||
265 | to be very small rather than GB. Many races found in the test under | ||
266 | xKB or xxMB limits. | ||
267 | (Memory behavior under GB and Memory behavior under MB shows very | ||
268 | different situation.) | ||
269 | |||
270 | 9.2 Shmem | ||
271 | Historically, memcg's shmem handling was poor and we saw some amount | ||
272 | of troubles here. This is because shmem is page-cache but can be | ||
273 | SwapCache. Test with shmem/tmpfs is always good test. | ||
274 | |||
275 | 9.3 Migration | ||
276 | For NUMA, migration is an another special case. To do easy test, cpuset | ||
277 | is useful. Following is a sample script to do migration. | ||
278 | |||
279 | mount -t cgroup -o cpuset none /opt/cpuset | ||
280 | |||
281 | mkdir /opt/cpuset/01 | ||
282 | echo 1 > /opt/cpuset/01/cpuset.cpus | ||
283 | echo 0 > /opt/cpuset/01/cpuset.mems | ||
284 | echo 1 > /opt/cpuset/01/cpuset.memory_migrate | ||
285 | mkdir /opt/cpuset/02 | ||
286 | echo 1 > /opt/cpuset/02/cpuset.cpus | ||
287 | echo 1 > /opt/cpuset/02/cpuset.mems | ||
288 | echo 1 > /opt/cpuset/02/cpuset.memory_migrate | ||
289 | |||
290 | In above set, when you moves a task from 01 to 02, page migration to | ||
291 | node 0 to node 1 will occur. Following is a script to migrate all | ||
292 | under cpuset. | ||
293 | -- | ||
294 | move_task() | ||
295 | { | ||
296 | for pid in $1 | ||
297 | do | ||
298 | /bin/echo $pid >$2/tasks 2>/dev/null | ||
299 | echo -n $pid | ||
300 | echo -n " " | ||
301 | done | ||
302 | echo END | ||
303 | } | ||
304 | |||
305 | G1_TASK=`cat ${G1}/tasks` | ||
306 | G2_TASK=`cat ${G2}/tasks` | ||
307 | move_task "${G1_TASK}" ${G2} & | ||
308 | -- | ||
309 | 9.4 Memory hotplug. | ||
310 | memory hotplug test is one of good test. | ||
311 | to offline memory, do following. | ||
312 | # echo offline > /sys/devices/system/memory/memoryXXX/state | ||
313 | (XXX is the place of memory) | ||
314 | This is an easy way to test page migration, too. | ||
315 | |||
316 | 9.5 mkdir/rmdir | ||
317 | When using hierarchy, mkdir/rmdir test should be done. | ||
318 | Use tests like the following. | ||
319 | |||
320 | echo 1 >/opt/cgroup/01/memory/use_hierarchy | ||
321 | mkdir /opt/cgroup/01/child_a | ||
322 | mkdir /opt/cgroup/01/child_b | ||
323 | |||
324 | set limit to 01. | ||
325 | add limit to 01/child_b | ||
326 | run jobs under child_a and child_b | ||
327 | |||
328 | create/delete following groups at random while jobs are running. | ||
329 | /opt/cgroup/01/child_a/child_aa | ||
330 | /opt/cgroup/01/child_b/child_bb | ||
331 | /opt/cgroup/01/child_c | ||
332 | |||
333 | running new jobs in new group is also good. | ||
334 | |||
335 | 9.6 Mount with other subsystems. | ||
336 | Mounting with other subsystems is a good test because there is a | ||
337 | race and lock dependency with other cgroup subsystems. | ||
338 | |||
339 | example) | ||
340 | # mount -t cgroup none /cgroup -t cpuset,memory,cpu,devices | ||
341 | |||
342 | and do task move, mkdir, rmdir etc...under this. | ||
diff --git a/Documentation/controllers/memory.txt b/Documentation/controllers/memory.txt index 1c07547d3f81..e1501964df1e 100644 --- a/Documentation/controllers/memory.txt +++ b/Documentation/controllers/memory.txt | |||
@@ -137,7 +137,32 @@ behind this approach is that a cgroup that aggressively uses a shared | |||
137 | page will eventually get charged for it (once it is uncharged from | 137 | page will eventually get charged for it (once it is uncharged from |
138 | the cgroup that brought it in -- this will happen on memory pressure). | 138 | the cgroup that brought it in -- this will happen on memory pressure). |
139 | 139 | ||
140 | 2.4 Reclaim | 140 | Exception: If CONFIG_CGROUP_CGROUP_MEM_RES_CTLR_SWAP is not used.. |
141 | When you do swapoff and make swapped-out pages of shmem(tmpfs) to | ||
142 | be backed into memory in force, charges for pages are accounted against the | ||
143 | caller of swapoff rather than the users of shmem. | ||
144 | |||
145 | |||
146 | 2.4 Swap Extension (CONFIG_CGROUP_MEM_RES_CTLR_SWAP) | ||
147 | Swap Extension allows you to record charge for swap. A swapped-in page is | ||
148 | charged back to original page allocator if possible. | ||
149 | |||
150 | When swap is accounted, following files are added. | ||
151 | - memory.memsw.usage_in_bytes. | ||
152 | - memory.memsw.limit_in_bytes. | ||
153 | |||
154 | usage of mem+swap is limited by memsw.limit_in_bytes. | ||
155 | |||
156 | Note: why 'mem+swap' rather than swap. | ||
157 | The global LRU(kswapd) can swap out arbitrary pages. Swap-out means | ||
158 | to move account from memory to swap...there is no change in usage of | ||
159 | mem+swap. | ||
160 | |||
161 | In other words, when we want to limit the usage of swap without affecting | ||
162 | global LRU, mem+swap limit is better than just limiting swap from OS point | ||
163 | of view. | ||
164 | |||
165 | 2.5 Reclaim | ||
141 | 166 | ||
142 | Each cgroup maintains a per cgroup LRU that consists of an active | 167 | Each cgroup maintains a per cgroup LRU that consists of an active |
143 | and inactive list. When a cgroup goes over its limit, we first try | 168 | and inactive list. When a cgroup goes over its limit, we first try |
@@ -207,12 +232,6 @@ exceeded. | |||
207 | The memory.stat file gives accounting information. Now, the number of | 232 | The memory.stat file gives accounting information. Now, the number of |
208 | caches, RSS and Active pages/Inactive pages are shown. | 233 | caches, RSS and Active pages/Inactive pages are shown. |
209 | 234 | ||
210 | The memory.force_empty gives an interface to drop *all* charges by force. | ||
211 | |||
212 | # echo 1 > memory.force_empty | ||
213 | |||
214 | will drop all charges in cgroup. Currently, this is maintained for test. | ||
215 | |||
216 | 4. Testing | 235 | 4. Testing |
217 | 236 | ||
218 | Balbir posted lmbench, AIM9, LTP and vmmstress results [10] and [11]. | 237 | Balbir posted lmbench, AIM9, LTP and vmmstress results [10] and [11]. |
@@ -242,10 +261,106 @@ reclaimed. | |||
242 | 261 | ||
243 | A cgroup can be removed by rmdir, but as discussed in sections 4.1 and 4.2, a | 262 | A cgroup can be removed by rmdir, but as discussed in sections 4.1 and 4.2, a |
244 | cgroup might have some charge associated with it, even though all | 263 | cgroup might have some charge associated with it, even though all |
245 | tasks have migrated away from it. Such charges are automatically dropped at | 264 | tasks have migrated away from it. |
246 | rmdir() if there are no tasks. | 265 | Such charges are freed(at default) or moved to its parent. When moved, |
266 | both of RSS and CACHES are moved to parent. | ||
267 | If both of them are busy, rmdir() returns -EBUSY. See 5.1 Also. | ||
268 | |||
269 | Charges recorded in swap information is not updated at removal of cgroup. | ||
270 | Recorded information is discarded and a cgroup which uses swap (swapcache) | ||
271 | will be charged as a new owner of it. | ||
272 | |||
273 | |||
274 | 5. Misc. interfaces. | ||
275 | |||
276 | 5.1 force_empty | ||
277 | memory.force_empty interface is provided to make cgroup's memory usage empty. | ||
278 | You can use this interface only when the cgroup has no tasks. | ||
279 | When writing anything to this | ||
280 | |||
281 | # echo 0 > memory.force_empty | ||
282 | |||
283 | Almost all pages tracked by this memcg will be unmapped and freed. Some of | ||
284 | pages cannot be freed because it's locked or in-use. Such pages are moved | ||
285 | to parent and this cgroup will be empty. But this may return -EBUSY in | ||
286 | some too busy case. | ||
287 | |||
288 | Typical use case of this interface is that calling this before rmdir(). | ||
289 | Because rmdir() moves all pages to parent, some out-of-use page caches can be | ||
290 | moved to the parent. If you want to avoid that, force_empty will be useful. | ||
291 | |||
292 | 5.2 stat file | ||
293 | memory.stat file includes following statistics (now) | ||
294 | cache - # of pages from page-cache and shmem. | ||
295 | rss - # of pages from anonymous memory. | ||
296 | pgpgin - # of event of charging | ||
297 | pgpgout - # of event of uncharging | ||
298 | active_anon - # of pages on active lru of anon, shmem. | ||
299 | inactive_anon - # of pages on active lru of anon, shmem | ||
300 | active_file - # of pages on active lru of file-cache | ||
301 | inactive_file - # of pages on inactive lru of file cache | ||
302 | unevictable - # of pages cannot be reclaimed.(mlocked etc) | ||
303 | |||
304 | Below is depend on CONFIG_DEBUG_VM. | ||
305 | inactive_ratio - VM inernal parameter. (see mm/page_alloc.c) | ||
306 | recent_rotated_anon - VM internal parameter. (see mm/vmscan.c) | ||
307 | recent_rotated_file - VM internal parameter. (see mm/vmscan.c) | ||
308 | recent_scanned_anon - VM internal parameter. (see mm/vmscan.c) | ||
309 | recent_scanned_file - VM internal parameter. (see mm/vmscan.c) | ||
310 | |||
311 | Memo: | ||
312 | recent_rotated means recent frequency of lru rotation. | ||
313 | recent_scanned means recent # of scans to lru. | ||
314 | showing for better debug please see the code for meanings. | ||
315 | |||
316 | |||
317 | 5.3 swappiness | ||
318 | Similar to /proc/sys/vm/swappiness, but affecting a hierarchy of groups only. | ||
319 | |||
320 | Following cgroup's swapiness can't be changed. | ||
321 | - root cgroup (uses /proc/sys/vm/swappiness). | ||
322 | - a cgroup which uses hierarchy and it has child cgroup. | ||
323 | - a cgroup which uses hierarchy and not the root of hierarchy. | ||
324 | |||
325 | |||
326 | 6. Hierarchy support | ||
327 | |||
328 | The memory controller supports a deep hierarchy and hierarchical accounting. | ||
329 | The hierarchy is created by creating the appropriate cgroups in the | ||
330 | cgroup filesystem. Consider for example, the following cgroup filesystem | ||
331 | hierarchy | ||
332 | |||
333 | root | ||
334 | / | \ | ||
335 | / | \ | ||
336 | a b c | ||
337 | | \ | ||
338 | | \ | ||
339 | d e | ||
340 | |||
341 | In the diagram above, with hierarchical accounting enabled, all memory | ||
342 | usage of e, is accounted to its ancestors up until the root (i.e, c and root), | ||
343 | that has memory.use_hierarchy enabled. If one of the ancestors goes over its | ||
344 | limit, the reclaim algorithm reclaims from the tasks in the ancestor and the | ||
345 | children of the ancestor. | ||
346 | |||
347 | 6.1 Enabling hierarchical accounting and reclaim | ||
348 | |||
349 | The memory controller by default disables the hierarchy feature. Support | ||
350 | can be enabled by writing 1 to memory.use_hierarchy file of the root cgroup | ||
351 | |||
352 | # echo 1 > memory.use_hierarchy | ||
353 | |||
354 | The feature can be disabled by | ||
355 | |||
356 | # echo 0 > memory.use_hierarchy | ||
357 | |||
358 | NOTE1: Enabling/disabling will fail if the cgroup already has other | ||
359 | cgroups created below it. | ||
360 | |||
361 | NOTE2: This feature can be enabled/disabled per subtree. | ||
247 | 362 | ||
248 | 5. TODO | 363 | 7. TODO |
249 | 364 | ||
250 | 1. Add support for accounting huge pages (as a separate controller) | 365 | 1. Add support for accounting huge pages (as a separate controller) |
251 | 2. Make per-cgroup scanner reclaim not-shared pages first | 366 | 2. Make per-cgroup scanner reclaim not-shared pages first |
diff --git a/Documentation/hwmon/abituguru-datasheet b/Documentation/hwmon/abituguru-datasheet index 4d184f2db0ea..d9251efdcec7 100644 --- a/Documentation/hwmon/abituguru-datasheet +++ b/Documentation/hwmon/abituguru-datasheet | |||
@@ -121,7 +121,7 @@ Once all bytes have been read data will hold 0x09, but there is no reason to | |||
121 | test for this. Notice that the number of bytes is bank address dependent see | 121 | test for this. Notice that the number of bytes is bank address dependent see |
122 | above and below. | 122 | above and below. |
123 | 123 | ||
124 | After completing a successfull read it is advised to put the uGuru back in | 124 | After completing a successful read it is advised to put the uGuru back in |
125 | ready mode, so that it is ready for the next read / write cycle. This way | 125 | ready mode, so that it is ready for the next read / write cycle. This way |
126 | if your program / driver is unloaded and later loaded again the detection | 126 | if your program / driver is unloaded and later loaded again the detection |
127 | algorithm described above will still work. | 127 | algorithm described above will still work. |
@@ -141,7 +141,7 @@ don't ask why this is the way it is. | |||
141 | 141 | ||
142 | Once DATA holds 0x01 read CMD it should hold 0xAC now. | 142 | Once DATA holds 0x01 read CMD it should hold 0xAC now. |
143 | 143 | ||
144 | After completing a successfull write it is advised to put the uGuru back in | 144 | After completing a successful write it is advised to put the uGuru back in |
145 | ready mode, so that it is ready for the next read / write cycle. This way | 145 | ready mode, so that it is ready for the next read / write cycle. This way |
146 | if your program / driver is unloaded and later loaded again the detection | 146 | if your program / driver is unloaded and later loaded again the detection |
147 | algorithm described above will still work. | 147 | algorithm described above will still work. |
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 532eacbbed62..fb849020aea9 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt | |||
@@ -1562,6 +1562,9 @@ and is between 256 and 4096 characters. It is defined in the file | |||
1562 | 1562 | ||
1563 | nosoftlockup [KNL] Disable the soft-lockup detector. | 1563 | nosoftlockup [KNL] Disable the soft-lockup detector. |
1564 | 1564 | ||
1565 | noswapaccount [KNL] Disable accounting of swap in memory resource | ||
1566 | controller. (See Documentation/controllers/memory.txt) | ||
1567 | |||
1565 | nosync [HW,M68K] Disables sync negotiation for all devices. | 1568 | nosync [HW,M68K] Disables sync negotiation for all devices. |
1566 | 1569 | ||
1567 | notsc [BUGS=X86-32] Disable Time Stamp Counter | 1570 | notsc [BUGS=X86-32] Disable Time Stamp Counter |
diff --git a/Documentation/powerpc/dts-bindings/fsl/board.txt b/Documentation/powerpc/dts-bindings/fsl/board.txt index 81a917ef96e9..6c974d28eeb4 100644 --- a/Documentation/powerpc/dts-bindings/fsl/board.txt +++ b/Documentation/powerpc/dts-bindings/fsl/board.txt | |||
@@ -18,7 +18,7 @@ This is the memory-mapped registers for on board FPGA. | |||
18 | 18 | ||
19 | Required properities: | 19 | Required properities: |
20 | - compatible : should be "fsl,fpga-pixis". | 20 | - compatible : should be "fsl,fpga-pixis". |
21 | - reg : should contain the address and the lenght of the FPPGA register | 21 | - reg : should contain the address and the length of the FPPGA register |
22 | set. | 22 | set. |
23 | 23 | ||
24 | Example (MPC8610HPCD): | 24 | Example (MPC8610HPCD): |
@@ -27,3 +27,33 @@ Example (MPC8610HPCD): | |||
27 | compatible = "fsl,fpga-pixis"; | 27 | compatible = "fsl,fpga-pixis"; |
28 | reg = <0xe8000000 32>; | 28 | reg = <0xe8000000 32>; |
29 | }; | 29 | }; |
30 | |||
31 | * Freescale BCSR GPIO banks | ||
32 | |||
33 | Some BCSR registers act as simple GPIO controllers, each such | ||
34 | register can be represented by the gpio-controller node. | ||
35 | |||
36 | Required properities: | ||
37 | - compatible : Should be "fsl,<board>-bcsr-gpio". | ||
38 | - reg : Should contain the address and the length of the GPIO bank | ||
39 | register. | ||
40 | - #gpio-cells : Should be two. The first cell is the pin number and the | ||
41 | second cell is used to specify optional paramters (currently unused). | ||
42 | - gpio-controller : Marks the port as GPIO controller. | ||
43 | |||
44 | Example: | ||
45 | |||
46 | bcsr@1,0 { | ||
47 | #address-cells = <1>; | ||
48 | #size-cells = <1>; | ||
49 | compatible = "fsl,mpc8360mds-bcsr"; | ||
50 | reg = <1 0 0x8000>; | ||
51 | ranges = <0 1 0 0x8000>; | ||
52 | |||
53 | bcsr13: gpio-controller@d { | ||
54 | #gpio-cells = <2>; | ||
55 | compatible = "fsl,mpc8360mds-bcsr-gpio"; | ||
56 | reg = <0xd 1>; | ||
57 | gpio-controller; | ||
58 | }; | ||
59 | }; | ||
diff --git a/Documentation/scsi/scsi_fc_transport.txt b/Documentation/scsi/scsi_fc_transport.txt index 38d324d62b25..e5b071d46619 100644 --- a/Documentation/scsi/scsi_fc_transport.txt +++ b/Documentation/scsi/scsi_fc_transport.txt | |||
@@ -191,7 +191,7 @@ Vport States: | |||
191 | This is equivalent to a driver "attach" on an adapter, which is | 191 | This is equivalent to a driver "attach" on an adapter, which is |
192 | independent of the adapter's link state. | 192 | independent of the adapter's link state. |
193 | - Instantiation of the vport on the FC link via ELS traffic, etc. | 193 | - Instantiation of the vport on the FC link via ELS traffic, etc. |
194 | This is equivalent to a "link up" and successfull link initialization. | 194 | This is equivalent to a "link up" and successful link initialization. |
195 | Further information can be found in the interfaces section below for | 195 | Further information can be found in the interfaces section below for |
196 | Vport Creation. | 196 | Vport Creation. |
197 | 197 | ||
@@ -320,7 +320,7 @@ Vport Creation: | |||
320 | This is equivalent to a driver "attach" on an adapter, which is | 320 | This is equivalent to a driver "attach" on an adapter, which is |
321 | independent of the adapter's link state. | 321 | independent of the adapter's link state. |
322 | - Instantiation of the vport on the FC link via ELS traffic, etc. | 322 | - Instantiation of the vport on the FC link via ELS traffic, etc. |
323 | This is equivalent to a "link up" and successfull link initialization. | 323 | This is equivalent to a "link up" and successful link initialization. |
324 | 324 | ||
325 | The LLDD's vport_create() function will not synchronously wait for both | 325 | The LLDD's vport_create() function will not synchronously wait for both |
326 | parts to be fully completed before returning. It must validate that the | 326 | parts to be fully completed before returning. It must validate that the |
diff --git a/Documentation/w1/masters/00-INDEX b/Documentation/w1/masters/00-INDEX index 7b0ceaaad7af..d63fa024ac05 100644 --- a/Documentation/w1/masters/00-INDEX +++ b/Documentation/w1/masters/00-INDEX | |||
@@ -4,5 +4,7 @@ ds2482 | |||
4 | - The Maxim/Dallas Semiconductor DS2482 provides 1-wire busses. | 4 | - The Maxim/Dallas Semiconductor DS2482 provides 1-wire busses. |
5 | ds2490 | 5 | ds2490 |
6 | - The Maxim/Dallas Semiconductor DS2490 builds USB <-> W1 bridges. | 6 | - The Maxim/Dallas Semiconductor DS2490 builds USB <-> W1 bridges. |
7 | mxc_w1 | ||
8 | - W1 master controller driver found on Freescale MX2/MX3 SoCs | ||
7 | w1-gpio | 9 | w1-gpio |
8 | - GPIO 1-wire bus master driver. | 10 | - GPIO 1-wire bus master driver. |
diff --git a/Documentation/w1/masters/mxc-w1 b/Documentation/w1/masters/mxc-w1 new file mode 100644 index 000000000000..97f6199a7f39 --- /dev/null +++ b/Documentation/w1/masters/mxc-w1 | |||
@@ -0,0 +1,11 @@ | |||
1 | Kernel driver mxc_w1 | ||
2 | ==================== | ||
3 | |||
4 | Supported chips: | ||
5 | * Freescale MX27, MX31 and probably other i.MX SoCs | ||
6 | Datasheets: | ||
7 | http://www.freescale.com/files/32bit/doc/data_sheet/MCIMX31.pdf?fpsp=1 | ||
8 | http://www.freescale.com/files/dsp/MCIMX27.pdf?fpsp=1 | ||
9 | |||
10 | Author: Originally based on Freescale code, prepared for mainline by | ||
11 | Sascha Hauer <s.hauer@pengutronix.de> | ||
diff --git a/Documentation/w1/w1.netlink b/Documentation/w1/w1.netlink index 3640c7c87d45..804445f745ed 100644 --- a/Documentation/w1/w1.netlink +++ b/Documentation/w1/w1.netlink | |||
@@ -5,69 +5,157 @@ Message types. | |||
5 | ============= | 5 | ============= |
6 | 6 | ||
7 | There are three types of messages between w1 core and userspace: | 7 | There are three types of messages between w1 core and userspace: |
8 | 1. Events. They are generated each time new master or slave device found | 8 | 1. Events. They are generated each time new master or slave device |
9 | either due to automatic or requested search. | 9 | found either due to automatic or requested search. |
10 | 2. Userspace commands. Includes read/write and search/alarm search comamnds. | 10 | 2. Userspace commands. |
11 | 3. Replies to userspace commands. | 11 | 3. Replies to userspace commands. |
12 | 12 | ||
13 | 13 | ||
14 | Protocol. | 14 | Protocol. |
15 | ======== | 15 | ======== |
16 | 16 | ||
17 | [struct cn_msg] - connector header. It's length field is equal to size of the attached data. | 17 | [struct cn_msg] - connector header. |
18 | Its length field is equal to size of the attached data | ||
18 | [struct w1_netlink_msg] - w1 netlink header. | 19 | [struct w1_netlink_msg] - w1 netlink header. |
19 | __u8 type - message type. | 20 | __u8 type - message type. |
20 | W1_SLAVE_ADD/W1_SLAVE_REMOVE - slave add/remove events. | 21 | W1_LIST_MASTERS |
21 | W1_MASTER_ADD/W1_MASTER_REMOVE - master add/remove events. | 22 | list current bus masters |
22 | W1_MASTER_CMD - userspace command for bus master device (search/alarm search). | 23 | W1_SLAVE_ADD/W1_SLAVE_REMOVE |
23 | W1_SLAVE_CMD - userspace command for slave device (read/write/ search/alarm search | 24 | slave add/remove events |
24 | for bus master device where given slave device found). | 25 | W1_MASTER_ADD/W1_MASTER_REMOVE |
26 | master add/remove events | ||
27 | W1_MASTER_CMD | ||
28 | userspace command for bus master | ||
29 | device (search/alarm search) | ||
30 | W1_SLAVE_CMD | ||
31 | userspace command for slave device | ||
32 | (read/write/touch) | ||
25 | __u8 res - reserved | 33 | __u8 res - reserved |
26 | __u16 len - size of attached to this header data. | 34 | __u16 len - size of data attached to this header data |
27 | union { | 35 | union { |
28 | __u8 id; - slave unique device id | 36 | __u8 id[8]; - slave unique device id |
29 | struct w1_mst { | 37 | struct w1_mst { |
30 | __u32 id; - master's id. | 38 | __u32 id; - master's id |
31 | __u32 res; - reserved | 39 | __u32 res; - reserved |
32 | } mst; | 40 | } mst; |
33 | } id; | 41 | } id; |
34 | 42 | ||
35 | [strucrt w1_netlink_cmd] - command for gived master or slave device. | 43 | [struct w1_netlink_cmd] - command for given master or slave device. |
36 | __u8 cmd - command opcode. | 44 | __u8 cmd - command opcode. |
37 | W1_CMD_READ - read command. | 45 | W1_CMD_READ - read command |
38 | W1_CMD_WRITE - write command. | 46 | W1_CMD_WRITE - write command |
39 | W1_CMD_SEARCH - search command. | 47 | W1_CMD_TOUCH - touch command |
40 | W1_CMD_ALARM_SEARCH - alarm search command. | 48 | (write and sample data back to userspace) |
49 | W1_CMD_SEARCH - search command | ||
50 | W1_CMD_ALARM_SEARCH - alarm search command | ||
41 | __u8 res - reserved | 51 | __u8 res - reserved |
42 | __u16 len - length of data for this command. | 52 | __u16 len - length of data for this command |
43 | For read command data must be allocated like for write command. | 53 | For read command data must be allocated like for write command |
44 | __u8 data[0] - data for this command. | 54 | __u8 data[0] - data for this command |
45 | 55 | ||
46 | 56 | ||
47 | Each connector message can include one or more w1_netlink_msg with zero of more attached w1_netlink_cmd messages. | 57 | Each connector message can include one or more w1_netlink_msg with |
58 | zero or more attached w1_netlink_cmd messages. | ||
48 | 59 | ||
49 | For event messages there are no w1_netlink_cmd embedded structures, only connector header | 60 | For event messages there are no w1_netlink_cmd embedded structures, |
50 | and w1_netlink_msg strucutre with "len" field being zero and filled type (one of event types) | 61 | only connector header and w1_netlink_msg strucutre with "len" field |
51 | and id - either 8 bytes of slave unique id in host order, or master's id, which is assigned | 62 | being zero and filled type (one of event types) and id: |
52 | to bus master device when it is added to w1 core. | 63 | either 8 bytes of slave unique id in host order, |
64 | or master's id, which is assigned to bus master device | ||
65 | when it is added to w1 core. | ||
66 | |||
67 | Currently replies to userspace commands are only generated for read | ||
68 | command request. One reply is generated exactly for one w1_netlink_cmd | ||
69 | read request. Replies are not combined when sent - i.e. typical reply | ||
70 | messages looks like the following: | ||
53 | 71 | ||
54 | Currently replies to userspace commands are only generated for read command request. | ||
55 | One reply is generated exactly for one w1_netlink_cmd read request. | ||
56 | Replies are not combined when sent - i.e. typical reply messages looks like the following: | ||
57 | [cn_msg][w1_netlink_msg][w1_netlink_cmd] | 72 | [cn_msg][w1_netlink_msg][w1_netlink_cmd] |
58 | cn_msg.len = sizeof(struct w1_netlink_msg) + sizeof(struct w1_netlink_cmd) + cmd->len; | 73 | cn_msg.len = sizeof(struct w1_netlink_msg) + |
74 | sizeof(struct w1_netlink_cmd) + | ||
75 | cmd->len; | ||
59 | w1_netlink_msg.len = sizeof(struct w1_netlink_cmd) + cmd->len; | 76 | w1_netlink_msg.len = sizeof(struct w1_netlink_cmd) + cmd->len; |
60 | w1_netlink_cmd.len = cmd->len; | 77 | w1_netlink_cmd.len = cmd->len; |
61 | 78 | ||
79 | Replies to W1_LIST_MASTERS should send a message back to the userspace | ||
80 | which will contain list of all registered master ids in the following | ||
81 | format: | ||
82 | |||
83 | cn_msg (CN_W1_IDX.CN_W1_VAL as id, len is equal to sizeof(struct | ||
84 | w1_netlink_msg) plus number of masters multipled by 4) | ||
85 | w1_netlink_msg (type: W1_LIST_MASTERS, len is equal to | ||
86 | number of masters multiplied by 4 (u32 size)) | ||
87 | id0 ... idN | ||
88 | |||
89 | Each message is at most 4k in size, so if number of master devices | ||
90 | exceeds this, it will be split into several messages, | ||
91 | cn.seq will be increased for each one. | ||
92 | |||
93 | W1 search and alarm search commands. | ||
94 | request: | ||
95 | [cn_msg] | ||
96 | [w1_netlink_msg type = W1_MASTER_CMD | ||
97 | id is equal to the bus master id to use for searching] | ||
98 | [w1_netlink_cmd cmd = W1_CMD_SEARCH or W1_CMD_ALARM_SEARCH] | ||
99 | |||
100 | reply: | ||
101 | [cn_msg, ack = 1 and increasing, 0 means the last message, | ||
102 | seq is equal to the request seq] | ||
103 | [w1_netlink_msg type = W1_MASTER_CMD] | ||
104 | [w1_netlink_cmd cmd = W1_CMD_SEARCH or W1_CMD_ALARM_SEARCH | ||
105 | len is equal to number of IDs multiplied by 8] | ||
106 | [64bit-id0 ... 64bit-idN] | ||
107 | Length in each header corresponds to the size of the data behind it, so | ||
108 | w1_netlink_cmd->len = N * 8; where N is number of IDs in this message. | ||
109 | Can be zero. | ||
110 | w1_netlink_msg->len = sizeof(struct w1_netlink_cmd) + N * 8; | ||
111 | cn_msg->len = sizeof(struct w1_netlink_msg) + | ||
112 | sizeof(struct w1_netlink_cmd) + | ||
113 | N*8; | ||
114 | |||
115 | W1 reset command. | ||
116 | [cn_msg] | ||
117 | [w1_netlink_msg type = W1_MASTER_CMD | ||
118 | id is equal to the bus master id to use for searching] | ||
119 | [w1_netlink_cmd cmd = W1_CMD_RESET] | ||
120 | |||
121 | |||
122 | Command status replies. | ||
123 | ====================== | ||
124 | |||
125 | Each command (either root, master or slave with or without w1_netlink_cmd | ||
126 | structure) will be 'acked' by the w1 core. Format of the reply is the same | ||
127 | as request message except that length parameters do not account for data | ||
128 | requested by the user, i.e. read/write/touch IO requests will not contain | ||
129 | data, so w1_netlink_cmd.len will be 0, w1_netlink_msg.len will be size | ||
130 | of the w1_netlink_cmd structure and cn_msg.len will be equal to the sum | ||
131 | of the sizeof(struct w1_netlink_msg) and sizeof(struct w1_netlink_cmd). | ||
132 | If reply is generated for master or root command (which do not have | ||
133 | w1_netlink_cmd attached), reply will contain only cn_msg and w1_netlink_msg | ||
134 | structires. | ||
135 | |||
136 | w1_netlink_msg.status field will carry positive error value | ||
137 | (EINVAL for example) or zero in case of success. | ||
138 | |||
139 | All other fields in every structure will mirror the same parameters in the | ||
140 | request message (except lengths as described above). | ||
141 | |||
142 | Status reply is generated for every w1_netlink_cmd embedded in the | ||
143 | w1_netlink_msg, if there are no w1_netlink_cmd structures, | ||
144 | reply will be generated for the w1_netlink_msg. | ||
145 | |||
146 | All w1_netlink_cmd command structures are handled in every w1_netlink_msg, | ||
147 | even if there were errors, only length mismatch interrupts message processing. | ||
148 | |||
62 | 149 | ||
63 | Operation steps in w1 core when new command is received. | 150 | Operation steps in w1 core when new command is received. |
64 | ======================================================= | 151 | ======================================================= |
65 | 152 | ||
66 | When new message (w1_netlink_msg) is received w1 core detects if it is master of slave request, | 153 | When new message (w1_netlink_msg) is received w1 core detects if it is |
67 | according to w1_netlink_msg.type field. | 154 | master or slave request, according to w1_netlink_msg.type field. |
68 | Then master or slave device is searched for. | 155 | Then master or slave device is searched for. |
69 | When found, master device (requested or those one on where slave device is found) is locked. | 156 | When found, master device (requested or those one on where slave device |
70 | If slave command is requested, then reset/select procedure is started to select given device. | 157 | is found) is locked. If slave command is requested, then reset/select |
158 | procedure is started to select given device. | ||
71 | 159 | ||
72 | Then all requested in w1_netlink_msg operations are performed one by one. | 160 | Then all requested in w1_netlink_msg operations are performed one by one. |
73 | If command requires reply (like read command) it is sent on command completion. | 161 | If command requires reply (like read command) it is sent on command completion. |
@@ -82,8 +170,8 @@ Connector [1] specific documentation. | |||
82 | Each connector message includes two u32 fields as "address". | 170 | Each connector message includes two u32 fields as "address". |
83 | w1 uses CN_W1_IDX and CN_W1_VAL defined in include/linux/connector.h header. | 171 | w1 uses CN_W1_IDX and CN_W1_VAL defined in include/linux/connector.h header. |
84 | Each message also includes sequence and acknowledge numbers. | 172 | Each message also includes sequence and acknowledge numbers. |
85 | Sequence number for event messages is appropriate bus master sequence number increased with | 173 | Sequence number for event messages is appropriate bus master sequence number |
86 | each event message sent "through" this master. | 174 | increased with each event message sent "through" this master. |
87 | Sequence number for userspace requests is set by userspace application. | 175 | Sequence number for userspace requests is set by userspace application. |
88 | Sequence number for reply is the same as was in request, and | 176 | Sequence number for reply is the same as was in request, and |
89 | acknowledge number is set to seq+1. | 177 | acknowledge number is set to seq+1. |
@@ -93,6 +181,6 @@ Additional documantion, source code examples. | |||
93 | ============================================ | 181 | ============================================ |
94 | 182 | ||
95 | 1. Documentation/connector | 183 | 1. Documentation/connector |
96 | 2. http://tservice.net.ru/~s0mbre/archive/w1 | 184 | 2. http://www.ioremap.net/archive/w1 |
97 | This archive includes userspace application w1d.c which | 185 | This archive includes userspace application w1d.c which uses |
98 | uses read/write/search commands for all master/slave devices found on the bus. | 186 | read/write/search commands for all master/slave devices found on the bus. |