Gentoo Archives: gentoo-dev

From: David Haller <gentoo@×××××××.de>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] Patch for nvidia-drivers 367.35-r1 for kernels > 4.7.0
Date: Sat, 06 Aug 2016 14:21:05
Message-Id: 20160806142012.3pzp7jk2iszoiuu4@grusum.endjinn.de
In Reply to: Re: [gentoo-dev] Patch for nvidia-drivers 367.35-r1 for kernels > 4.7.0 by Natanael Olaiz
1 Hello,
2
3 On Sat, 06 Aug 2016, Natanael Olaiz wrote:
4 >Thank you for your patch. It was a good example to answer my question.
5 >
6 >But about the patch itself, I see that you are commented the code for
7 >radix_tree_empty(...). In my patch I renamed it and it only usage instead,
8 >so I'm sure it's calling the same code. I don't know the expected
9 >compatibility with the kernel function implementation... But without
10 >knowing the specific code for neither the nvidia driver nor the kernel, I
11 >think the rename is safer...
12
13 If you're in doubt or hit any trouble, yes, definitely change/adapt
14 the patch to only rename that function and use the renamed function in
15 the nvidia-driver as in your original patch. Keep/adapt the stuff
16 about kernel-versions though. That's the "safe" approach.
17
18 That "just put it in /etc/portage/patches/..." should work tough :)
19
20
21 I've looked quite sharp at the code, i.e. in the nvidia code
22
23 static bool radix_tree_empty(struct radix_tree_root *tree)
24 {
25 void *dummy;
26 return radix_tree_gang_lookup(tree, &dummy, 0, 1) == 0;
27 }
28
29 vs. the kernel function
30
31 static inline bool radix_tree_empty(struct radix_tree_root *root)
32 {
33 return root->rnode == NULL;
34 }
35
36 *oik* I miss a check for root != NULL there ;)
37
38 Anyway, it was quite clear, that the driver calls kernel-stuff at this
39 point anyway, radix_tree_gang_lookup() is a kernel function. (I love
40 to use mc for digging for stuff like this!)
41
42 So, digging into the kernel-source I came to the conclusion that
43 calling the _kernel code_(!)
44
45 radix_tree_gang_lookup(tree, &dummy, 0, 1);
46
47 actually _is_ (or SHOULD BE) equivalent to the kernel code for
48 the new
49
50 radix_tree_empty(tree);
51
52 and the latter should be faster (unless the compiler optimizes the
53 'radix_tree_gang_lookup(root, &dummy, 0, 1)' call away).
54
55 All this applies if and only if the last two arguments of
56 radix_tree_gang_lookup() are 0 and 1! And yes, I did go through the
57 code of radix_tree_gang_lookup() step by step (repeatedly) until I was
58 sure enough that the code is equivalent). But I'm not a C guru. I
59 might have missed something even important. So, if more guys firm in C
60 can check this ...
61
62 As I'm a guy generally trusting the kernel guys _a lot_ and that
63 nvidia assumedly got it right implementing 'radix_tree_empty(tree)'
64 via 'radix_tree_gang_lookup(tree, &dummy, 0, 1);' and I think those
65 two equivalent (with 0, 1 being the 3rd and 4th parameters!), I tried
66 it, and it worked.
67
68 And Meino has not yet complained. AFAIR he's around long enough to
69 have complained by now (and circumvented problems with the patch).
70 I'll ping him on the -user ML though in a parallel mail.
71
72 Recap: calling the kernel function in this way (via the nvidia function)
73
74 radix_tree_gang_lookup(tree, &dummy, 0, 1);
75
76 is IMHO equivalent to calling the kernel function
77
78 radix_tree_empty(tree);
79
80 and on this I based my patch on. I'm rather sure from looking at the
81 code. It worked in a short test. Meino has not complained yet. If you
82 want a "sure"/"safe" approach, go with renaming the function in the
83 nvidia-code, or wait a bit if Meino pipes up, he should've been
84 running the driver with my patch for a week by now. Or until an
85 official patch crops up.
86
87 Or, take precautions, some other way to boot+chroot, and keep the
88 "old" driver handy or to disable it, build a binary package of the
89 previous driver, have an older kernel ready etc. pp., you know the
90 drill, don't you?
91
92 -dnh
93
94 --
95 MCSE: "Microsoft Certified Stupidity enclosed" -- A. Spengler

Replies

Subject Author
Re: [gentoo-dev] Patch for nvidia-drivers 367.35-r1 for kernels > 4.7.0 Natanael Olaiz <nolaiz@×××××.com>