Re: [PATCH v3 2/2] iov_iter: Don't deal with iter->copy_mc in memcpy_from_iter_mc()

From: David Howells
Date: Fri Aug 18 2023 - 09:35:35 EST


Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:

> This patch only does that for the 'user_backed' thing, which was a similar
> case.

It makes some things a bit bigger, makes some a bit smaller:

__iov_iter_get_pages_alloc dcr 0x331 -> 0x32a -0x7
_copy_from_iter dcr 0x36e -> 0x36a -0x4
_copy_from_iter_flushcache inc 0x359 -> 0x36b +0x12
_copy_mc_to_iter dcr 0x3a7 -> 0x39b -0xc
_copy_to_iter inc 0x358 -> 0x359 +0x1
copy_page_to_iter_nofault.part.0 dcr 0x3f1 -> 0x3ef -0x2
csum_and_copy_from_iter dcr 0x3e8 -> 0x3e4 -0x4
csum_and_copy_to_iter inc 0x46a -> 0x46d +0x3
dup_iter inc 0x34 -> 0x39 +0x5
fault_in_iov_iter_readable inc 0x9b -> 0xa0 +0x5
fault_in_iov_iter_writeable inc 0x9b -> 0xa0 +0x5
first_iovec_segment inc 0x4a -> 0x51 +0x7
import_single_range dcr 0x62 -> 0x40 -0x22
import_ubuf dcr 0x65 -> 0x43 -0x22
iov_iter_advance inc 0xd7 -> 0x103 +0x2c
iov_iter_alignment inc 0xe0 -> 0xe2 +0x2
iov_iter_extract_pages dcr 0x418 -> 0x416 -0x2
iov_iter_init dcr 0x31 -> 0x27 -0xa
iov_iter_is_aligned inc 0xf3 -> 0x108 +0x15
iov_iter_npages inc 0x119 -> 0x11a +0x1
iov_iter_revert inc 0x88 -> 0x99 +0x11
iov_iter_single_seg_count inc 0x38 -> 0x3e +0x6
iov_iter_ubuf new 0x39
iov_iter_zero inc 0x34f -> 0x353 +0x4
iter_iov new 0x17

Adding an extra patch to get rid of the bitfields and using a u8 for the type
and bools for the flags makes very little difference on top of the above:

__iov_iter_get_pages_alloc inc 0x32a -> 0x32f +0x5
_copy_from_iter inc 0x36a -> 0x36d +0x3
copy_page_from_iter_atomic.part.0 inc 0x3cf -> 0x3d2 +0x3
csum_and_copy_to_iter dcr 0x46d -> 0x46a -0x3
iov_iter_advance dcr 0x103 -> 0xfd -0x6
iov_iter_extract_pages inc 0x416 -> 0x417 +0x1
iov_iter_init inc 0x27 -> 0x2d +0x6
iov_iter_revert dcr 0x99 -> 0x95 -0x4

For reference, I generated the stats with:

nm build3/lib/iov_iter.o | sort >a
... change...
nm build3/lib/iov_iter.o | sort >b
perl analyse.pl a b

where analyse.pl is attached.

David
---
#!/usr/bin/perl -w
use strict;

die "$0 <file_a> <file_b>" if ($#ARGV != 1);
my ($file_a, $file_b) = @ARGV;
die "$file_a: File not found\n" unless -r $file_a;
die "$file_b: File not found\n" unless -r $file_b;

my %a = ();
my %b = ();
my %c = ();

sub read_one($$$)
{
my ($file, $list, $all) = @_;
my $last = undef;

open FD, "<$file" || die $file;
while (<FD>) {
if (/([0-9a-f][0-9a-f]+) [Tt] ([_a-zA-Z0-9.]*)/) {
my $addr = hex $1;
my $sym = $2;
#print $addr, " ", $sym, "\n";

my %obj = (
sym => $sym,
addr => $addr,
size => 0
);

$list->{$sym} = \%obj;
$all->{$sym} = 1;

if ($last) {
$last->{size} = $addr - $last->{addr};
}

$last = \%obj;
}
}
close(FD);
}

read_one($file_a, \%a, \%c);
read_one($file_b, \%b, \%c);

foreach my $sym (sort keys %c) {
my $as = -1;
my $bs = -1;

$as = $a{$sym}->{size} if (exists($a{$sym}));
$bs = $b{$sym}->{size} if (exists($b{$sym}));

next if ($as == $bs);
#next if ($sym =~ /__UNIQUE_ID/);

if ($as == -1) {
printf "%-40s new 0x%x\n", $sym, $bs;
} elsif ($bs == -1) {
printf "%-40s del 0x%x\n", $sym, $as;
} elsif ($bs > $as) {
printf "%-40s inc 0x%x -> 0x%x +0x%x\n", $sym, $as, $bs, $bs - $as;
} else {
printf "%-40s dcr 0x%x -> 0x%x -0x%x\n", $sym, $as, $bs, $as - $bs;
}
}