Re: [PATCH 49/52] perf tools: Build programs to copy 32-bit compatibility VDSOs

From: Adrian Hunter
Date: Wed Jul 23 2014 - 09:56:27 EST


On 07/23/2014 03:48 PM, Jiri Olsa wrote:
> On Tue, Jul 22, 2014 at 04:17:58PM +0300, Adrian Hunter wrote:
>
> SNIP
>
>> index 1f67aa0..45ab040 100644
>> --- a/tools/perf/config/Makefile
>> +++ b/tools/perf/config/Makefile
>> @@ -604,6 +604,27 @@ ifdef HAVE_KVM_STAT_SUPPORT
>> CFLAGS += -DHAVE_KVM_STAT_SUPPORT
>> endif
>>
>> +ifeq (${IS_64_BIT}, 1)
>> + ifndef NO_PERF_READ_VDSO32
>> + CAN_DO := $(shell echo "main() {}" | ${CC} -m32 -x c - >/dev/null 2>/dev/null && echo 1 || echo 0)
>> + ifneq (${CAN_DO}, 1)
>> + NO_PERF_READ_VDSO32 := 1
>> + endif
>> + endif
>> + ifneq (${IS_X86_64}, 1)
>> + NO_PERF_READ_VDSOX32 := 1
>> + endif
>> + ifndef NO_PERF_READ_VDSOX32
>> + CAN_DO := $(shell echo 'main() {}' | ${CC} -mx32 -x c - >/dev/null 2>/dev/null && echo 1 || echo 0)
>> + ifneq (${CAN_DO}, 1)
>> + NO_PERF_READ_VDSOX32 := 1
>> + endif
>> + endif
>
> please move those check into feature config code under config/features/..

I will look at doing that.

>
> SNIP
>
>> +++ b/tools/perf/perf-read-vdso.c
>> @@ -0,0 +1,59 @@
>> +#include <stdio.h>
>> +#include <string.h>
>> +
>> +#define VDSO__MAP_NAME "[vdso]"
>> +
>> +static int find_vdso_map(void **start, void **end)
>> +{
>> + FILE *maps;
>> + char line[128];
>> + int found = 0;
>> +
>> + maps = fopen("/proc/self/maps", "r");
>> + if (!maps) {
>> + fprintf(stderr, "vdso: cannot open maps\n");
>> + return -1;
>> + }
>> +
>> + while (!found && fgets(line, sizeof(line), maps)) {
>> + int m = -1;
>> +
>> + /* We care only about private r-x mappings. */
>> + if (2 != sscanf(line, "%p-%p r-xp %*x %*x:%*x %*u %n",
>> + start, end, &m))
>> + continue;
>> + if (m < 0)
>> + continue;
>> +
>> + if (!strncmp(&line[m], VDSO__MAP_NAME,
>> + sizeof(VDSO__MAP_NAME) - 1))
>> + found = 1;
>> + }
>> +
>> + fclose(maps);
>> + return !found;
>> +}
>
> hum, any easy way to use/share find_vdso_map from vdso.c?
> I guess this way is more straighforward and clear.. it's
> probably not worthy for function this simple

Would have to create another source file and include it.
I am not sure it is worth it. Maybe Arnaldo can decide?

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/