summaryrefslogtreecommitdiff
path: root/src/script/find_waiters.pl
blob: c89d2b1a49db7ca758cb07e84725faf1f839d1bc (plain)
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
#!/usr/bin/perl

my %waiting;  # context => what where what is "inode ..." or "dir ..."
my %hist;     # context => history since waited
my @waiting;

my $line = 0;
while (<>) {
	#print $line . $_ if /0x8d4f6a0/;
	$line++;
	if (/add_waiter/) {
		my ($c) = /(0x\w+)/;
		my ($what) = / on (.*\])/;
		#print "$line add_waiter $c $what\n" if /0x8d4f6a0/;
		$waiting{$c} = $what
			if $what && !$waiting{$c};
		$hist{$c} .= "$line: $_";
		unless (grep {$_ eq $c} @waiting) {
			push( @waiting, $c );
		}
	}
	#if (/finish_waiting/) {
	#	my ($c) = /(0x\w+)/;
	#	$hist{$c} .= "$line: $_";
	#}
	if (/take_waiting/) {
		my ($c) = /(0x\w+)/;
		if (/SKIPPING/) {
			#print "skipping\n" if /0x8d4f6a0/;
			$hist{$c} .= "$line: $_";
		} elsif (/took/) {
			#print "took\n" if /0x8d4f6a0/;
			delete $waiting{$c};
			delete $hist{$c};
			@waiting = grep {$_ ne $c} @waiting;
		} else {
			die "i don't understand: $_";
		}
	}
}

for my $c (@waiting) {
	print "---- lost waiter $c $waiting{$c}
$hist{$c}
";
}