spu_task_sync.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. /*
  2. * Cell Broadband Engine OProfile Support
  3. *
  4. * (C) Copyright IBM Corporation 2006
  5. *
  6. * Author: Maynard Johnson <maynardj@us.ibm.com>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version
  11. * 2 of the License, or (at your option) any later version.
  12. */
  13. /* The purpose of this file is to handle SPU event task switching
  14. * and to record SPU context information into the OProfile
  15. * event buffer.
  16. *
  17. * Additionally, the spu_sync_buffer function is provided as a helper
  18. * for recoding actual SPU program counter samples to the event buffer.
  19. */
  20. #include <linux/dcookies.h>
  21. #include <linux/kref.h>
  22. #include <linux/mm.h>
  23. #include <linux/fs.h>
  24. #include <linux/module.h>
  25. #include <linux/notifier.h>
  26. #include <linux/numa.h>
  27. #include <linux/oprofile.h>
  28. #include <linux/spinlock.h>
  29. #include "pr_util.h"
  30. #define RELEASE_ALL 9999
  31. static DEFINE_SPINLOCK(buffer_lock);
  32. static DEFINE_SPINLOCK(cache_lock);
  33. static int num_spu_nodes;
  34. int spu_prof_num_nodes;
  35. struct spu_buffer spu_buff[MAX_NUMNODES * SPUS_PER_NODE];
  36. struct delayed_work spu_work;
  37. static unsigned max_spu_buff;
  38. static void spu_buff_add(unsigned long int value, int spu)
  39. {
  40. /* spu buff is a circular buffer. Add entries to the
  41. * head. Head is the index to store the next value.
  42. * The buffer is full when there is one available entry
  43. * in the queue, i.e. head and tail can't be equal.
  44. * That way we can tell the difference between the
  45. * buffer being full versus empty.
  46. *
  47. * ASSUPTION: the buffer_lock is held when this function
  48. * is called to lock the buffer, head and tail.
  49. */
  50. int full = 1;
  51. if (spu_buff[spu].head >= spu_buff[spu].tail) {
  52. if ((spu_buff[spu].head - spu_buff[spu].tail)
  53. < (max_spu_buff - 1))
  54. full = 0;
  55. } else if (spu_buff[spu].tail > spu_buff[spu].head) {
  56. if ((spu_buff[spu].tail - spu_buff[spu].head)
  57. > 1)
  58. full = 0;
  59. }
  60. if (!full) {
  61. spu_buff[spu].buff[spu_buff[spu].head] = value;
  62. spu_buff[spu].head++;
  63. if (spu_buff[spu].head >= max_spu_buff)
  64. spu_buff[spu].head = 0;
  65. } else {
  66. /* From the user's perspective make the SPU buffer
  67. * size management/overflow look like we are using
  68. * per cpu buffers. The user uses the same
  69. * per cpu parameter to adjust the SPU buffer size.
  70. * Increment the sample_lost_overflow to inform
  71. * the user the buffer size needs to be increased.
  72. */
  73. oprofile_cpu_buffer_inc_smpl_lost();
  74. }
  75. }
  76. /* This function copies the per SPU buffers to the
  77. * OProfile kernel buffer.
  78. */
  79. void sync_spu_buff(void)
  80. {
  81. int spu;
  82. unsigned long flags;
  83. int curr_head;
  84. for (spu = 0; spu < num_spu_nodes; spu++) {
  85. /* In case there was an issue and the buffer didn't
  86. * get created skip it.
  87. */
  88. if (spu_buff[spu].buff == NULL)
  89. continue;
  90. /* Hold the lock to make sure the head/tail
  91. * doesn't change while spu_buff_add() is
  92. * deciding if the buffer is full or not.
  93. * Being a little paranoid.
  94. */
  95. spin_lock_irqsave(&buffer_lock, flags);
  96. curr_head = spu_buff[spu].head;
  97. spin_unlock_irqrestore(&buffer_lock, flags);
  98. /* Transfer the current contents to the kernel buffer.
  99. * data can still be added to the head of the buffer.
  100. */
  101. oprofile_put_buff(spu_buff[spu].buff,
  102. spu_buff[spu].tail,
  103. curr_head, max_spu_buff);
  104. spin_lock_irqsave(&buffer_lock, flags);
  105. spu_buff[spu].tail = curr_head;
  106. spin_unlock_irqrestore(&buffer_lock, flags);
  107. }
  108. }
  109. static void wq_sync_spu_buff(struct work_struct *work)
  110. {
  111. /* move data from spu buffers to kernel buffer */
  112. sync_spu_buff();
  113. /* only reschedule if profiling is not done */
  114. if (spu_prof_running)
  115. schedule_delayed_work(&spu_work, DEFAULT_TIMER_EXPIRE);
  116. }
  117. /* Container for caching information about an active SPU task. */
  118. struct cached_info {
  119. struct vma_to_fileoffset_map *map;
  120. struct spu *the_spu; /* needed to access pointer to local_store */
  121. struct kref cache_ref;
  122. };
  123. static struct cached_info *spu_info[MAX_NUMNODES * 8];
  124. static void destroy_cached_info(struct kref *kref)
  125. {
  126. struct cached_info *info;
  127. info = container_of(kref, struct cached_info, cache_ref);
  128. vma_map_free(info->map);
  129. kfree(info);
  130. module_put(THIS_MODULE);
  131. }
  132. /* Return the cached_info for the passed SPU number.
  133. * ATTENTION: Callers are responsible for obtaining the
  134. * cache_lock if needed prior to invoking this function.
  135. */
  136. static struct cached_info *get_cached_info(struct spu *the_spu, int spu_num)
  137. {
  138. struct kref *ref;
  139. struct cached_info *ret_info;
  140. if (spu_num >= num_spu_nodes) {
  141. printk(KERN_ERR "SPU_PROF: "
  142. "%s, line %d: Invalid index %d into spu info cache\n",
  143. __func__, __LINE__, spu_num);
  144. ret_info = NULL;
  145. goto out;
  146. }
  147. if (!spu_info[spu_num] && the_spu) {
  148. ref = spu_get_profile_private_kref(the_spu->ctx);
  149. if (ref) {
  150. spu_info[spu_num] = container_of(ref, struct cached_info, cache_ref);
  151. kref_get(&spu_info[spu_num]->cache_ref);
  152. }
  153. }
  154. ret_info = spu_info[spu_num];
  155. out:
  156. return ret_info;
  157. }
  158. /* Looks for cached info for the passed spu. If not found, the
  159. * cached info is created for the passed spu.
  160. * Returns 0 for success; otherwise, -1 for error.
  161. */
  162. static int
  163. prepare_cached_spu_info(struct spu *spu, unsigned long objectId)
  164. {
  165. unsigned long flags;
  166. struct vma_to_fileoffset_map *new_map;
  167. int retval = 0;
  168. struct cached_info *info;
  169. /* We won't bother getting cache_lock here since
  170. * don't do anything with the cached_info that's returned.
  171. */
  172. info = get_cached_info(spu, spu->number);
  173. if (info) {
  174. pr_debug("Found cached SPU info.\n");
  175. goto out;
  176. }
  177. /* Create cached_info and set spu_info[spu->number] to point to it.
  178. * spu->number is a system-wide value, not a per-node value.
  179. */
  180. info = kzalloc(sizeof(struct cached_info), GFP_KERNEL);
  181. if (!info) {
  182. printk(KERN_ERR "SPU_PROF: "
  183. "%s, line %d: create vma_map failed\n",
  184. __func__, __LINE__);
  185. retval = -ENOMEM;
  186. goto err_alloc;
  187. }
  188. new_map = create_vma_map(spu, objectId);
  189. if (!new_map) {
  190. printk(KERN_ERR "SPU_PROF: "
  191. "%s, line %d: create vma_map failed\n",
  192. __func__, __LINE__);
  193. retval = -ENOMEM;
  194. goto err_alloc;
  195. }
  196. pr_debug("Created vma_map\n");
  197. info->map = new_map;
  198. info->the_spu = spu;
  199. kref_init(&info->cache_ref);
  200. spin_lock_irqsave(&cache_lock, flags);
  201. spu_info[spu->number] = info;
  202. /* Increment count before passing off ref to SPUFS. */
  203. kref_get(&info->cache_ref);
  204. /* We increment the module refcount here since SPUFS is
  205. * responsible for the final destruction of the cached_info,
  206. * and it must be able to access the destroy_cached_info()
  207. * function defined in the OProfile module. We decrement
  208. * the module refcount in destroy_cached_info.
  209. */
  210. try_module_get(THIS_MODULE);
  211. spu_set_profile_private_kref(spu->ctx, &info->cache_ref,
  212. destroy_cached_info);
  213. spin_unlock_irqrestore(&cache_lock, flags);
  214. goto out;
  215. err_alloc:
  216. kfree(info);
  217. out:
  218. return retval;
  219. }
  220. /*
  221. * NOTE: The caller is responsible for locking the
  222. * cache_lock prior to calling this function.
  223. */
  224. static int release_cached_info(int spu_index)
  225. {
  226. int index, end;
  227. if (spu_index == RELEASE_ALL) {
  228. end = num_spu_nodes;
  229. index = 0;
  230. } else {
  231. if (spu_index >= num_spu_nodes) {
  232. printk(KERN_ERR "SPU_PROF: "
  233. "%s, line %d: "
  234. "Invalid index %d into spu info cache\n",
  235. __func__, __LINE__, spu_index);
  236. goto out;
  237. }
  238. end = spu_index + 1;
  239. index = spu_index;
  240. }
  241. for (; index < end; index++) {
  242. if (spu_info[index]) {
  243. kref_put(&spu_info[index]->cache_ref,
  244. destroy_cached_info);
  245. spu_info[index] = NULL;
  246. }
  247. }
  248. out:
  249. return 0;
  250. }
  251. /* The source code for fast_get_dcookie was "borrowed"
  252. * from drivers/oprofile/buffer_sync.c.
  253. */
  254. /* Optimisation. We can manage without taking the dcookie sem
  255. * because we cannot reach this code without at least one
  256. * dcookie user still being registered (namely, the reader
  257. * of the event buffer).
  258. */
  259. static inline unsigned long fast_get_dcookie(struct path *path)
  260. {
  261. unsigned long cookie;
  262. if (path->dentry->d_flags & DCACHE_COOKIE)
  263. return (unsigned long)path->dentry;
  264. get_dcookie(path, &cookie);
  265. return cookie;
  266. }
  267. /* Look up the dcookie for the task's first VM_EXECUTABLE mapping,
  268. * which corresponds loosely to "application name". Also, determine
  269. * the offset for the SPU ELF object. If computed offset is
  270. * non-zero, it implies an embedded SPU object; otherwise, it's a
  271. * separate SPU binary, in which case we retrieve it's dcookie.
  272. * For the embedded case, we must determine if SPU ELF is embedded
  273. * in the executable application or another file (i.e., shared lib).
  274. * If embedded in a shared lib, we must get the dcookie and return
  275. * that to the caller.
  276. */
  277. static unsigned long
  278. get_exec_dcookie_and_offset(struct spu *spu, unsigned int *offsetp,
  279. unsigned long *spu_bin_dcookie,
  280. unsigned long spu_ref)
  281. {
  282. unsigned long app_cookie = 0;
  283. unsigned int my_offset = 0;
  284. struct file *app = NULL;
  285. struct vm_area_struct *vma;
  286. struct mm_struct *mm = spu->mm;
  287. if (!mm)
  288. goto out;
  289. down_read(&mm->mmap_sem);
  290. for (vma = mm->mmap; vma; vma = vma->vm_next) {
  291. if (!vma->vm_file)
  292. continue;
  293. if (!(vma->vm_flags & VM_EXECUTABLE))
  294. continue;
  295. app_cookie = fast_get_dcookie(&vma->vm_file->f_path);
  296. pr_debug("got dcookie for %s\n",
  297. vma->vm_file->f_dentry->d_name.name);
  298. app = vma->vm_file;
  299. break;
  300. }
  301. for (vma = mm->mmap; vma; vma = vma->vm_next) {
  302. if (vma->vm_start > spu_ref || vma->vm_end <= spu_ref)
  303. continue;
  304. my_offset = spu_ref - vma->vm_start;
  305. if (!vma->vm_file)
  306. goto fail_no_image_cookie;
  307. pr_debug("Found spu ELF at %X(object-id:%lx) for file %s\n",
  308. my_offset, spu_ref,
  309. vma->vm_file->f_dentry->d_name.name);
  310. *offsetp = my_offset;
  311. break;
  312. }
  313. *spu_bin_dcookie = fast_get_dcookie(&vma->vm_file->f_path);
  314. pr_debug("got dcookie for %s\n", vma->vm_file->f_dentry->d_name.name);
  315. up_read(&mm->mmap_sem);
  316. out:
  317. return app_cookie;
  318. fail_no_image_cookie:
  319. up_read(&mm->mmap_sem);
  320. printk(KERN_ERR "SPU_PROF: "
  321. "%s, line %d: Cannot find dcookie for SPU binary\n",
  322. __func__, __LINE__);
  323. goto out;
  324. }
  325. /* This function finds or creates cached context information for the
  326. * passed SPU and records SPU context information into the OProfile
  327. * event buffer.
  328. */
  329. static int process_context_switch(struct spu *spu, unsigned long objectId)
  330. {
  331. unsigned long flags;
  332. int retval;
  333. unsigned int offset = 0;
  334. unsigned long spu_cookie = 0, app_dcookie;
  335. retval = prepare_cached_spu_info(spu, objectId);
  336. if (retval)
  337. goto out;
  338. /* Get dcookie first because a mutex_lock is taken in that
  339. * code path, so interrupts must not be disabled.
  340. */
  341. app_dcookie = get_exec_dcookie_and_offset(spu, &offset, &spu_cookie, objectId);
  342. if (!app_dcookie || !spu_cookie) {
  343. retval = -ENOENT;
  344. goto out;
  345. }
  346. /* Record context info in event buffer */
  347. spin_lock_irqsave(&buffer_lock, flags);
  348. spu_buff_add(ESCAPE_CODE, spu->number);
  349. spu_buff_add(SPU_CTX_SWITCH_CODE, spu->number);
  350. spu_buff_add(spu->number, spu->number);
  351. spu_buff_add(spu->pid, spu->number);
  352. spu_buff_add(spu->tgid, spu->number);
  353. spu_buff_add(app_dcookie, spu->number);
  354. spu_buff_add(spu_cookie, spu->number);
  355. spu_buff_add(offset, spu->number);
  356. /* Set flag to indicate SPU PC data can now be written out. If
  357. * the SPU program counter data is seen before an SPU context
  358. * record is seen, the postprocessing will fail.
  359. */
  360. spu_buff[spu->number].ctx_sw_seen = 1;
  361. spin_unlock_irqrestore(&buffer_lock, flags);
  362. smp_wmb(); /* insure spu event buffer updates are written */
  363. /* don't want entries intermingled... */
  364. out:
  365. return retval;
  366. }
  367. /*
  368. * This function is invoked on either a bind_context or unbind_context.
  369. * If called for an unbind_context, the val arg is 0; otherwise,
  370. * it is the object-id value for the spu context.
  371. * The data arg is of type 'struct spu *'.
  372. */
  373. static int spu_active_notify(struct notifier_block *self, unsigned long val,
  374. void *data)
  375. {
  376. int retval;
  377. unsigned long flags;
  378. struct spu *the_spu = data;
  379. pr_debug("SPU event notification arrived\n");
  380. if (!val) {
  381. spin_lock_irqsave(&cache_lock, flags);
  382. retval = release_cached_info(the_spu->number);
  383. spin_unlock_irqrestore(&cache_lock, flags);
  384. } else {
  385. retval = process_context_switch(the_spu, val);
  386. }
  387. return retval;
  388. }
  389. static struct notifier_block spu_active = {
  390. .notifier_call = spu_active_notify,
  391. };
  392. static int number_of_online_nodes(void)
  393. {
  394. u32 cpu; u32 tmp;
  395. int nodes = 0;
  396. for_each_online_cpu(cpu) {
  397. tmp = cbe_cpu_to_node(cpu) + 1;
  398. if (tmp > nodes)
  399. nodes++;
  400. }
  401. return nodes;
  402. }
  403. static int oprofile_spu_buff_create(void)
  404. {
  405. int spu;
  406. max_spu_buff = oprofile_get_cpu_buffer_size();
  407. for (spu = 0; spu < num_spu_nodes; spu++) {
  408. /* create circular buffers to store the data in.
  409. * use locks to manage accessing the buffers
  410. */
  411. spu_buff[spu].head = 0;
  412. spu_buff[spu].tail = 0;
  413. /*
  414. * Create a buffer for each SPU. Can't reliably
  415. * create a single buffer for all spus due to not
  416. * enough contiguous kernel memory.
  417. */
  418. spu_buff[spu].buff = kzalloc((max_spu_buff
  419. * sizeof(unsigned long)),
  420. GFP_KERNEL);
  421. if (!spu_buff[spu].buff) {
  422. printk(KERN_ERR "SPU_PROF: "
  423. "%s, line %d: oprofile_spu_buff_create "
  424. "failed to allocate spu buffer %d.\n",
  425. __func__, __LINE__, spu);
  426. /* release the spu buffers that have been allocated */
  427. while (spu >= 0) {
  428. kfree(spu_buff[spu].buff);
  429. spu_buff[spu].buff = 0;
  430. spu--;
  431. }
  432. return -ENOMEM;
  433. }
  434. }
  435. return 0;
  436. }
  437. /* The main purpose of this function is to synchronize
  438. * OProfile with SPUFS by registering to be notified of
  439. * SPU task switches.
  440. *
  441. * NOTE: When profiling SPUs, we must ensure that only
  442. * spu_sync_start is invoked and not the generic sync_start
  443. * in drivers/oprofile/oprof.c. A return value of
  444. * SKIP_GENERIC_SYNC or SYNC_START_ERROR will
  445. * accomplish this.
  446. */
  447. int spu_sync_start(void)
  448. {
  449. int spu;
  450. int ret = SKIP_GENERIC_SYNC;
  451. int register_ret;
  452. unsigned long flags = 0;
  453. spu_prof_num_nodes = number_of_online_nodes();
  454. num_spu_nodes = spu_prof_num_nodes * 8;
  455. INIT_DELAYED_WORK(&spu_work, wq_sync_spu_buff);
  456. /* create buffer for storing the SPU data to put in
  457. * the kernel buffer.
  458. */
  459. ret = oprofile_spu_buff_create();
  460. if (ret)
  461. goto out;
  462. spin_lock_irqsave(&buffer_lock, flags);
  463. for (spu = 0; spu < num_spu_nodes; spu++) {
  464. spu_buff_add(ESCAPE_CODE, spu);
  465. spu_buff_add(SPU_PROFILING_CODE, spu);
  466. spu_buff_add(num_spu_nodes, spu);
  467. }
  468. spin_unlock_irqrestore(&buffer_lock, flags);
  469. for (spu = 0; spu < num_spu_nodes; spu++) {
  470. spu_buff[spu].ctx_sw_seen = 0;
  471. spu_buff[spu].last_guard_val = 0;
  472. }
  473. /* Register for SPU events */
  474. register_ret = spu_switch_event_register(&spu_active);
  475. if (register_ret) {
  476. ret = SYNC_START_ERROR;
  477. goto out;
  478. }
  479. pr_debug("spu_sync_start -- running.\n");
  480. out:
  481. return ret;
  482. }
  483. /* Record SPU program counter samples to the oprofile event buffer. */
  484. void spu_sync_buffer(int spu_num, unsigned int *samples,
  485. int num_samples)
  486. {
  487. unsigned long long file_offset;
  488. unsigned long flags;
  489. int i;
  490. struct vma_to_fileoffset_map *map;
  491. struct spu *the_spu;
  492. unsigned long long spu_num_ll = spu_num;
  493. unsigned long long spu_num_shifted = spu_num_ll << 32;
  494. struct cached_info *c_info;
  495. /* We need to obtain the cache_lock here because it's
  496. * possible that after getting the cached_info, the SPU job
  497. * corresponding to this cached_info may end, thus resulting
  498. * in the destruction of the cached_info.
  499. */
  500. spin_lock_irqsave(&cache_lock, flags);
  501. c_info = get_cached_info(NULL, spu_num);
  502. if (!c_info) {
  503. /* This legitimately happens when the SPU task ends before all
  504. * samples are recorded.
  505. * No big deal -- so we just drop a few samples.
  506. */
  507. pr_debug("SPU_PROF: No cached SPU contex "
  508. "for SPU #%d. Dropping samples.\n", spu_num);
  509. goto out;
  510. }
  511. map = c_info->map;
  512. the_spu = c_info->the_spu;
  513. spin_lock(&buffer_lock);
  514. for (i = 0; i < num_samples; i++) {
  515. unsigned int sample = *(samples+i);
  516. int grd_val = 0;
  517. file_offset = 0;
  518. if (sample == 0)
  519. continue;
  520. file_offset = vma_map_lookup( map, sample, the_spu, &grd_val);
  521. /* If overlays are used by this SPU application, the guard
  522. * value is non-zero, indicating which overlay section is in
  523. * use. We need to discard samples taken during the time
  524. * period which an overlay occurs (i.e., guard value changes).
  525. */
  526. if (grd_val && grd_val != spu_buff[spu_num].last_guard_val) {
  527. spu_buff[spu_num].last_guard_val = grd_val;
  528. /* Drop the rest of the samples. */
  529. break;
  530. }
  531. /* We must ensure that the SPU context switch has been written
  532. * out before samples for the SPU. Otherwise, the SPU context
  533. * information is not available and the postprocessing of the
  534. * SPU PC will fail with no available anonymous map information.
  535. */
  536. if (spu_buff[spu_num].ctx_sw_seen)
  537. spu_buff_add((file_offset | spu_num_shifted),
  538. spu_num);
  539. }
  540. spin_unlock(&buffer_lock);
  541. out:
  542. spin_unlock_irqrestore(&cache_lock, flags);
  543. }
  544. int spu_sync_stop(void)
  545. {
  546. unsigned long flags = 0;
  547. int ret;
  548. int k;
  549. ret = spu_switch_event_unregister(&spu_active);
  550. if (ret)
  551. printk(KERN_ERR "SPU_PROF: "
  552. "%s, line %d: spu_switch_event_unregister " \
  553. "returned %d\n",
  554. __func__, __LINE__, ret);
  555. /* flush any remaining data in the per SPU buffers */
  556. sync_spu_buff();
  557. spin_lock_irqsave(&cache_lock, flags);
  558. ret = release_cached_info(RELEASE_ALL);
  559. spin_unlock_irqrestore(&cache_lock, flags);
  560. /* remove scheduled work queue item rather then waiting
  561. * for every queued entry to execute. Then flush pending
  562. * system wide buffer to event buffer.
  563. */
  564. cancel_delayed_work(&spu_work);
  565. for (k = 0; k < num_spu_nodes; k++) {
  566. spu_buff[k].ctx_sw_seen = 0;
  567. /*
  568. * spu_sys_buff will be null if there was a problem
  569. * allocating the buffer. Only delete if it exists.
  570. */
  571. kfree(spu_buff[k].buff);
  572. spu_buff[k].buff = 0;
  573. }
  574. pr_debug("spu_sync_stop -- done.\n");
  575. return ret;
  576. }