From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753766AbcADWQc (ORCPT ); Mon, 4 Jan 2016 17:16:32 -0500 Received: from mail-ig0-f181.google.com ([209.85.213.181]:33166 "EHLO mail-ig0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753121AbcADWQY (ORCPT ); Mon, 4 Jan 2016 17:16:24 -0500 From: Vince Weaver X-Google-Original-From: Vince Weaver Date: Mon, 4 Jan 2016 17:19:13 -0500 (EST) X-X-Sender: vince@macbook-air To: linux-kernel@vger.kernel.org cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Stephane Eranian Subject: perf_event_open() ABI compatability Message-ID: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org So I think this might be revisiting an issue that has come up before, but we're having backward compatability issues with PAPI and libpfm4 and the perf_event_open() system call. If a user specifies exclude_guest=1 on an older kernel that doesn't support it, we get the awesome EINVAL error return code and it often takes hours to track down the cause. Now in theory the ABI is maintained via the "size" field. So you can figure out the size of the attr struct by setting an invalid size and then getting E2BIG with size set to the value the kernel expects. This doesn't help with exclude_guest though, as that's in the giant union in the middle of the attr, and there's absolutely no mechanism at all to tell when that has been extended. Is there any solution to all of this, except having to carry around a big table of kernel version numbers for when features were added? Ideally we would somehow want E2BIG returned plus the size of __reserved_1 if the value of __reserved_1 is not zero. I suppose at this point in the game it's too late for this to be much help and we're going to have to work around the problem forever anyway. Vince