bear20081015
    @wowo:wowo,我最近在梳理pm runtime和suspend之间的关系。碰到有一种case有点不太理解,请帮我看看: 1.一个设备在系统suspend之前处于RPM_SUSPENDED状态;此时dev->power.usage_count=0,dev->power.runtime_state = RPM_SUSPENDED; 2.在dev->prepare函数, system suspend框架会调用pm_runtime_get_noresume,此时dev->power.usage_count=1, runtime_state仍然是RPM_SUSPENEDED; 3.接着,system suspend会调用device_suspend_late,这个函数中调用了__pm_runtime_disable()。如果恰好在此之前,有人希望通过pm_runtime_get来resume这个设备,那么就会把一个pending的resume request放到pm runtime work queue上;此时usage_count=2, runtime_state = RPM_SUSPENDED; 4. 在__pm_runtime_disable中,函数会调用__pm_runtime_barrier,这会取消step3中的pending resume请求。 但不会将usage_count减1。此时usage_count=2, runtime_state = RPM_SUSPENDED。 5. 当系统resume回来的时候,它会调用pm_runtime_put来将usage_count减1。 此时usage_count=1, runtime_state = RPM_SUSPENDED。 可以看到,经过这几个步骤后,device的runtime_state和usage_count出现了不匹配的情况,runtime_state=RPM_SUSPENDED的时候usage_count应该是0,但现在变成了1。我做的实验也是这样。不知道这算不算runtime的bug呢?还是我上面哪一步有问题?请指教,谢谢!
    Linux内核同步机制之(四):spin lock  发表时间:2015-06-02 10:53
    wowo
    @artake:谢谢夸奖,不过膜拜、love就不需要了,哈哈~~
    Linux设备模型(1)_基本概念  发表时间:2015-06-01 20:24
    wowo
    @bear20081015:至于runtime PM,确实只是开了一个头。因为RPM的使用比较简单,但内部实现涉及到的知识点就多了,因此还没有时间去写。可以直接评论交流,非常欢迎~~~~
    Linux内核同步机制之(四):spin lock  发表时间:2015-06-01 20:23
    wowo
    @bear20081015:我来插一句: ARM架构提供了non-blocking的同步机制(也称作synchronization primitives),确实比较高效、实用。但该机制需要一些额外机制的支撑,也就是您所提到的local monitor和global monitor。monitor特别是global monitor的实现, 和cache、MMU等没有直接关系。但是,对那些特殊位置的memory,如non-cacheable、cache-disable等,需要在PE之外实现monitor功能,而并不是所有厂商都会做这些事情。 对arm trusted firmware来说,它无法假设厂商的具体行为,因此为了确保同步的有效,就不得不使用软件的互斥机制(bakery lock)。 而对Linux kernel而言,kernel是在单核、preemptive disable的情况下启动的,等到真正使用spin lock的时候,一切都准备就绪了,因此也就没什么问题了。 具体可参考DDI0487A_d_armv8_arm.pdf: For Shareable memory locations, in some implementations and for some memory types, the properties of the global monitor require functionality outside the PE. Some system implementations might not implement this functionality for all locations of memory. In particular, this can apply to: • Any type of memory in the system implementation that does not support hardware cache coherency. • Non-cacheable memory, or memory treated as Non-cacheable, in an implementation that does support hardware cache coherency. In such a system, it is defined by the system: • Whether the global monitor is implemented. • If the global monitor is implemented, which address ranges or memory types it monitors ... Therefore, architecturally-compliant software that requires mutual exclusion must not rely on using the Load-Exclusive/Store-Exclusive mechanism, and must instead use a software algorithm such as Lamport’s Bakery algorithm to achieve mutual exclusion.
    Linux内核同步机制之(四):spin lock  发表时间:2015-06-01 20:18
    artake
    群主写得实在是太好了,膜拜,I love you
    Linux设备模型(1)_基本概念  发表时间:2015-06-01 15:55
    bear20081015
    @linuxer:我个人还是感觉是有点关系的,否则不可能arm trustfirm要多此一举去实现一个软件的spinlock锁,而且这个锁就是在cache没有enable的情况下使用的。但还是感谢你耐心的回答!另外多问一句,我看到你们的pm runtime的系列文章似乎只开了个头,我最近在这一块有点疑问,不知道你们后续文章有时间表么?或者就在评论区里面大家讨论一下?
    Linux内核同步机制之(四):spin lock  发表时间:2015-06-01 15:34
    linuxer
    @bear20081015:local和global monitor是实现在L1和L2 cache中的 --------------------------------------------------- 我看原文上是说local和global monitor是实现在L1和L2 memory system中,我是觉得local timer以及global timer应该是和L1和L2 cache是否enable或者disable无关,即便是L1和L2 cache disable了,local monitor和global monitor也应该是可以工作的 当然,这也是我的猜测而已,仅供参考
    Linux内核同步机制之(四):spin lock  发表时间:2015-06-01 12:34
    bear20081015
    @linuxer:linux,我摘录的那一段都是在描述arm中如何支持exclusive access的。我的理解是:spinlock从本质上来说确实就是内存中的一个u32数据,但如何支持ldx和stx这两条指令的原子性呢?硬件上肯定要有东西来支撑它,我理解就是local monitor和global monitor。正如这句话“Each processor that supports exclusive accesses has a local monitor.”。进一步从arm的文档中看,local和global monitor是实现在L1和L2 cache中的。所以我才怀疑当L1,L2 cache被disable掉的时候,ldx和stx指令都无效了,也就不能使用spinlock了。我这两天看了下ARM的trust firmware里的bakery lock,我不确定自己理解的对不对,但是看起来就是一个软件上的锁似乎就是为了代替在cpu刚上电时cache关掉时各个CPU的race condition,如果能够直接用spinlock的话似乎就没这个必要了吧。
    Linux内核同步机制之(四):spin lock  发表时间:2015-06-01 10:43
    linuxer
    @bear20081015:你摘录的英文都是在描述Shareability,但是你的问题却在说cache,你是不是把Shareability和Cacheability搞混了?
    Linux内核同步机制之(四):spin lock  发表时间:2015-06-01 09:12
    wowo
    @zzq57683968:多谢关注,我会尽力做的:-)
    Linux CPU core的电源管理(2)_cpu topology  发表时间:2015-06-01 08:39

共7862条621/787上一页 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 下一页
Copyright @ 2013-2015 蜗窝科技 All rights reserved. Powered by emlog