[Yum-devel] RFC: yum+rpm ppc64p7 patches

Phil Knirsch pknirsch at redhat.com
Wed Apr 18 13:37:06 UTC 2012


On 04/18/2012 02:22 PM, James Antill wrote:
> On Fri, 2012-03-23 at 19:22 +0100, Phil Knirsch wrote:
>> Hi folks.
>>
>> Here the promised patches to add support for adding a power7
>> optimized
>> arch to ppc64 for rpm and yum.
>>
>> It's pretty similar to the ARM neon support code from dgilmore, only
>> that i needed to add the detection properly in rpm as well.
>>
>> I've tested them to some degree with a local repository containing
>> packages build with --target ppc64p7 and then installing, removing
>> and
>> updating the respective package. Selection worked as expected,
>> preferred
>> ppc64p7 obviously on a Power7 box.
>>
>> The detection code is a bit rough, both in yum and rpm, but i didn't
>> want to manually parse the C struct from /proc/self/auxv.
>
>   Bah, never replied to this for the yum side.
>
>> diff -up yum-3.4.3/rpmUtils/arch.py.ppc64p7 yum-3.4.3/rpmUtils/arch.py
>> --- yum-3.4.3/rpmUtils/arch.py.ppc64p7  2012-03-23 19:06:05.554002837
>> +0100
>> +++ yum-3.4.3/rpmUtils/arch.py  2012-03-23 19:06:09.143997990 +0100
>> @@ -2,6 +2,8 @@
>>   #
>>
>>   import os
>> +import subprocess
>> +import tempfile
>>   import rpm
>>
>>   _ppc64_native_is_best = True
>> @@ -31,6 +33,7 @@ arches = {
>>       "ia32e": "x86_64",
>>
>>       # ppc
>> +    "ppc64p7": "ppc64",
>>       "ppc64pseries": "ppc64",
>>       "ppc64iseries": "ppc64",
>>       "ppc64": "ppc",
>> @@ -260,13 +260,27 @@ def getCanonPPCArch(arch):
>>           if line.find("machine") != -1:
>>               machine = line.split(':')[1]
>>               break
>> -    if machine is None:
>> +
>> +    platform = None
>> +    so = tempfile.NamedTemporaryFile(mode="rw+b")
>> +    obj = subprocess.Popen(["LD_SHOW_AUXV=1 /bin/true"], shell=True, close_fds=True, stdout=so.file)
>> +    obj.wait()
>> +    so.file.seek(0, 0)
>> +    for line in so.readlines():
>> +        if line.find("AT_PLATFORM:") != -1:
>> +            platform = line.split(':')[1]
>
>
>   This is a bit meh ... is it possible we could get an rpm API or
> something to do this? Does the above work in anaconda? Not sure if there
> are any other gotchas with having to be able to run other applications,
> esp. this far down.
>   Also seems like it could use pipes instead of files ... but then again
> it's all in the ppc code, so as long as it works...
>

Yea, it's kinda butt ugly, but the problem is that rpm doesn't have an 
API for it, even less so for the python part that would be required.

The latest patch version for rpm at least does it in a decently sane way 
where a struct is being populated with AT_PLATFORM and AT_HWCAPS 
information to be used for defaultMachine() stuff.

The other 2 options are to either look at /proc/cpuinfo or to use ENV 
where at the end the AT stuff is being "injected", but the IBM folks 
strongly recommended not to use the former, and the later is really 
fishy and unstable when someone modifies ENV before we reach that part 
in yum. So i've picked the best of all the bad choices. :/

>> +    if machine is None and platform is None:
>>           return arch
>>
>> -    if machine.find("CHRP IBM") != -1:
>> -        return "ppc64pseries"
>> -    if machine.find("iSeries") != -1:
>> -        return "ppc64iseries"
>> +    if platform != None and platform.find("power7") != -1:
>> +        return "ppc64p7"
>> +
>> +    if machine != None:
>> +        if machine.find("CHRP IBM") != -1:
>> +            return "ppc64pseries"
>> +        if machine.find("iSeries") != -1:
>> +            return "ppc64iseries"
>>       return arch
>
>   I think what you want to do here is just add:
>
> + if platofrm is None:
> +     arch
> + if platform.find("power7") != -1:
> +     return "ppc64p7"
> +
>

Ye, i wanted to rewrite that a bit anyway, as we want this to trigger 
for power8, power9 etc as well obviously. I'll rework the 2nd part a bit 
more.

Thanks & regards, Phil

-- 
Philipp Knirsch              | Tel.:  +49-711-96437-470
Supervisor Core Services     | Fax.:  +49-711-96437-111
Red Hat GmbH                 | Email: Phil Knirsch <pknirsch at redhat.com>
Hauptstaetterstr. 58         | Web:   http://www.redhat.com/
D-70178 Stuttgart, Germany


More information about the Yum-devel mailing list