aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/patch-kernel
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2010-01-26 15:42:38 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2010-01-26 15:42:38 -0500
commit03391693a95900875b0973569d2d73ff3aa8972e (patch)
tree01ede0d09e01353573e3c13ee15441d76d2eec1b /scripts/patch-kernel
parent8e469ebd6dc32cbaf620e134d79f740bf0ebab79 (diff)
NFSv4.1: Don't call nfs4_schedule_state_recovery() unnecessarily
Currently, nfs4_handle_exception() will call it twice if called with an error of -NFS4ERR_STALE_CLIENTID, -NFS4ERR_STALE_STATEID or -NFS4ERR_EXPIRED. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
Diffstat (limited to 'scripts/patch-kernel')
0 files changed, 0 insertions, 0 deletions
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 621 622 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 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970
#!/usr/bin/env python

import copy
import math
import numpy.random as dist
import StringIO

import unittest

import schedcat.generator.tasks as tg
import schedcat.generator.tasksets as tsgen

def const(v):
    def _draw():
        return v
    return _draw

class node:
    def __init__(self, id=-1, level=-1, graph = None):
        self.id = id
        self.graph = graph
        self.isSrc = False
        self.isSink = False
        self.isSpine = False
        # list of predecessor nodes
        self.pred = []
        # list of successor nodes
        self.succ = []
        # list of inbound edges
        self.inEdges = []
        # list of outbound edges
        self.outEdges = []

        # variables used during generation
        self.privLevel = level

    def isAncestor(self, other):
        q = copy.copy(self.pred)
        while q:
            v = q.pop()
            if v == other:
                return True
            q.extend(v.pred)
        return False

    def isDescendant(self, other):
        return other.isAncestor(self)

    def degreeIn(self):
        return len(self.inEdges)

    def degreeOut(self):
        return len(self.outEdges)

    def degree(self):
        return len(self.inEdges) + len(self.outEdges)

    def __repr__(self):
        graph_id = self.graph.id if self.graph and hasattr(self.graph, 'id') else -1
        stem = 'node_%s(gid:%d,l:%d,src:%d,sink:%d,spine:%d)' % (self.id, graph_id, self.privLevel, self.isSrc, self.isSink, self.isSpine)
        pred_str = 'preds{'
        for n in self.pred:
            pred_str += str(n.id) + ','
        pred_str += '}'
        succ_str = 'succs{'
        for n in self.succ:
            succ_str += str(n.id) + ','
        succ_str += '}'
        return '%s %s %s' % (stem, pred_str, succ_str)

    def dot(self):
        attr = []
        if self.isSrc or self.isSink:
            attr.append('shape=doublecircle')
        else:
            attr.append('shape=circle')
        if not (self.isSrc or self.isSink):
            attr.append('style=""')
            attr.append('color=""')
        elif self.isSrc:
            attr.append('style=filled')
            attr.append('color="#56A0D3"')
        elif self.isSink:
            attr.append('style=filled')
            attr.append('color="#E04050D3"')
        node_str = 'node [%s]; %d;' % (', '.join(attr), self.id)
        if hasattr(self, 'task'):
            # assumes time is in microseconds
            cost_str = format(self.task.cost/1000.0, '.4f').rstrip('0').rstrip('.')
            period_str = format(self.task.period/1000.0, '.4f').rstrip('0').rstrip('.')
            extra_str = ' /* node_%d: exec: %s, period: %s, split: %d, cluster %d, is_src: %s, is_sink: %s */' % (
                self.id, cost_str, period_str, self.task.split, self.task.partition, self.isSrc, self.isSink)
        else:
            extra_str = ''
        return node_str + extra_str

class edge:
    def __init__(self, a, b):
        self.p = a
        self.s = b
        self.wss = 0

    def __repr__(self):
        return 'node_%d -> node_%d' % (self.p.id, self.s.id)

    def dot(self):
        criticalPath = (self.p.isSpine and self.s.isSpine and abs(self.s.privLevel - self.p.privLevel) == 1)
        edge_str = '%d -> %d [%s];' % (self.p.id, self.s.id, ('style="", color=dimgrey', 'style=bold, color="#E04050"')[criticalPath])
        wss_str = format(self.wss, '.4f').rstrip('0').rstrip('.')
        extra_str = ' /* parent: node_%d, child: node_%d, wss: %s, is_spine: %s */' % (self.p.id, self.s.id, wss_str, criticalPath)
        return edge_str + extra_str

class graph:
    def __init__(self):
        self.nodes = []
        self.sources = []
        self.sinks = []
        self.edges = []
        self.nodesAtLevel = {}
        self.depth = 0
        # assume a sporadic release from sources
        self.isSporadic = True

    def __repr__(self):
        s = ''
        for i in self.nodes:
            n = str(i)
            s += n + '\n'
        return s

    def dot(self):
        outs = StringIO.StringIO()
        outs.write('digraph G {\n')
        outs.write('\trankdir=LR;\n')
        outs.write('\tratio="compress";\n')
        outs.write('\tsize="11,8.5";\n')

        graph_name = 'graph' if not hasattr(self, 'id') else 'graph_%d' % self.id
        extra_str = '/* %s: depth: %d, nr_nodes: %d, nr_src: %d, nr_sink: %d, nr_edges: %d */' % (
            graph_name, self.depth, len(self.nodes), len(self.sources), len(self.sinks), len(self.edges))
        outs.write('\t%s\n' % extra_str)

        # draw nodes
        for n in self.nodes:
            outs.write('\t')
            outs.write(n.dot())
            outs.write('\n')

        # draw edges
        for e in self.edges:
            outs.write('\t')
            outs.write(e.dot())
            outs.write('\n')

        orphans = [n for n in self.nodes if not n.succ]
        for o in orphans:
            outs.write('\t%d;\n' % o.id)

        # end the graph
        outs.write('}')
        return outs.getvalue()

def bound_graph_latency(g):
    sporadic_latency = 0
    graph_latency = 0

    if len(g.nodes) == 1:
        sporadic_latency = g.nodes[0].task.response_time
    else:
        # We assume all nodes share a period
        period = g.nodes[0].task.period

        for n in g.nodes:
            n.latency = 0 if not n.isSrc else max(period, n.task.response_time)
            n.isQueued = False
        for e in g.edges:
            e.longest = False

        # accumulate latencies down the graph
        queue = g.sources[:]
        while len(queue) != 0:
            # breadth-first propagation of latencies from srcs to sinks
            v = queue.pop(0)
            v.isQueued = False
            for e in v.outEdges:
                latency = v.latency + max(period, e.s.task.response_time)
                # if we updated the latency, then we need to revisit the node
                if latency > e.s.latency:
                    # clear out old longest
                    cur_longest = [e for e in e.s.inEdges if e.longest == True]
                    if len(cur_longest) > 0:
                        assert len(cur_longest) == 1
                        cur_longest[0].longest = False
                    # set new longest
                    e.longest = True
                    e.s.latency = latency
                    if e.s.isQueued == False:
                        e.s.isQueued = True
                        queue.append(e.s)

        max_sink = max(g.sinks, key=lambda n: n.latency)
        longest_path = []
        longest_path.append(max_sink)
        queue.append(max_sink)
        while len(queue) != 0:
            v = queue.pop(0)
            if v.inEdges:
                longest_edge = [e for e in v.inEdges if e.longest is True]
                assert len(longest_edge) == 1
                longest_edge = longest_edge[0]
                # prepend to the path
                longest_path.insert(0, longest_edge.p)
                queue.append(longest_edge.p)
            else:
                assert v.isSrc
        assert len(longest_path) <= g.depth

        depth_latency = len(longest_path) * period
        sporadic_latency = max_sink.latency - depth_latency

        if g.isSporadic:
            # factor the accumlated latency into grapth-depth and
            # tardiness-based components

            if max_sink.task.response_time < period:
                # Optimization:
                #  * Remove one period from depth_latency
                #  * Add response time of sink to depth_latency
                # (We don't modify sporadic_latency since we know the sink's
                # contribition was 0.)
                graph_latency = depth_latency - period + max_sink.task.response_time
            else:
                graph_latency = depth_latency
        else:
            # TODO: Optimize of the sink tasks response time
            # Rate-based bound:
            graph_latency = 4 * depth_latency

    assert sporadic_latency >= 0
    assert graph_latency >= 0

#    print 'depth:           \t',g.depth
#    print 'period:          \t',period
#    print 'd*p:             \t',g.depth * period
#    print 'combined:        \t', sporadic_latency + graph_latency
#    print 'sporadic latency:\t', sporadic_latency
#    print 'graph latency:   \t', graph_latency
#    raw_input('press enter')

    return sporadic_latency + graph_latency

# tighter bound w/o 'max-period'
def bound_graph_latency2(g):
    if len(g.nodes) == 1:
        return g.nodes[0].task.response_time
    else:
        # We assume all nodes share a period
        period = g.nodes[0].task.period

        for n in g.nodes:
            n.latency = 0 if not n.isSrc else max(period, n.task.response_time)
            n.isQueued = False
        for e in g.edges:
            e.longest = False

        # accumulate latencies down the graph
        queue = g.sources[:]
        while len(queue) != 0:
            # breadth-first propagation of latencies from srcs to sinks
            v = queue.pop(0)
            v.isQueued = False
            for e in v.outEdges:
                # only sum up the task response time
                latency = v.latency + e.s.task.response_time
                # if we updated the latency, then we need to revisit the node
                if latency > e.s.latency:
                    # clear out old longest
                    cur_longest = [e for e in e.s.inEdges if e.longest == True]
                    if len(cur_longest) > 0:
                        assert len(cur_longest) == 1
                        cur_longest[0].longest = False
                    # set new longest
                    e.longest = True
                    e.s.latency = latency
                    if e.s.isQueued == False:
                        e.s.isQueued = True
                        queue.append(e.s)

        max_sink = max(g.sinks, key=lambda n: n.latency)
        return max_sink.latency

def compute_ideal_graph_latency(g):
    graph_latency = 0
    if len(g.nodes) == 1:
        graph_latency = g.nodes[0].task.cost
    else:
        for n in g.nodes:
            n.latency = 0 if not n.isSrc else n.task.cost
            n.isQueued = False

        queue = g.sources[:]

        while len(queue) != 0:
            # breadth-first propagation of latencies from srcs to sinks
            v = queue.pop(0)
            v.isQueued = False
            for e in v.outEdges:
                latency = v.latency + e.s.task.cost
                # if we updated the latency, then we need to revisit the node
                if latency > e.s.latency:
                    e.s.latency = latency
                    if e.s.isQueued == False:
                        e.s.isQueued = True
                        queue.append(e.s)
        graph_latency = max(g.sinks, key=lambda n: n.latency).latency
    assert graph_latency > 0
    return graph_latency

def compute_hrt_ideal_graph_latency(g):
    graph_latency = 0
    if len(g.nodes) == 1:
        graph_latency = g.nodes[0].task.deadline
    else:
        for n in g.nodes:
            n.latency = 0 if not n.isSrc else n.task.deadline
            n.isQueued = False

        queue = g.sources[:]

        while len(queue) != 0:
            # breadth-first propagation of latencies from srcs to sinks
            v = queue.pop(0)
            v.isQueued = False
            for e in v.outEdges:
                latency = v.latency + e.s.task.deadline
                # if we updated the latency, then we need to revisit the node
                if latency > e.s.latency:
                    e.s.latency = latency
                    if e.s.isQueued == False:
                        e.s.isQueued = True
                        queue.append(e.s)
        graph_latency = max(g.sinks, key=lambda n: n.latency).latency
    assert graph_latency > 0
    return graph_latency

def link(up, down):
    up.succ.append(down)
    down.pred.append(up)

def eligible_predecessor_of(n, maxDeg = None):
    def _check(candidate):
        if candidate.isSink:
            return False
        if maxDeg != None and maxDeg != 0 and len(candidate.succ) >= maxDeg:
            return False
        if candidate in n.pred:
            return False
        return True
    return _check

def pick_predecessor(g, fromLevel, leap_picker, is_eligible_predecessor):
    nStepsBack = min(max(1, leap_picker()), fromLevel)
    targetLevel = fromLevel - nStepsBack
    for l in range(targetLevel,-1,-1):
        candidates = [x for x in g.nodesAtLevel[l] if is_eligible_predecessor(x)]
        if not candidates:
            continue
        return tg.uniform_choice(candidates)()
    return None