From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 130313 invoked by alias); 6 Mar 2017 22:35:54 -0000 Mailing-List: contact gnu-gabi-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: gnu-gabi-owner@sourceware.org Received: (qmail 130301 invoked by uid 89); 6 Mar 2017 22:35:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.99.2 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy=depicts, clarity, Hx-languages-length:4186, HX-Gm-Message-State:AMke39l X-Spam-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: mail-qk0-f170.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=JpTZxSWXvPuXwN+s71gMSivTK1157x1lkGpjffTT2YY=; b=igZfELvHsDxI2Ovvei5YZpuHkWm2AZKStI3TbSKQgl21iEoOE7dg6QCv4Hl+3BWLQD QJZm+Oqaf0ZoDkQyFVoWraNzpwI2pkEDhW1udxgJeHJl9WxDp8/QKnvbIaLDNoQEe11K 3h+jN92lbmgHovF2e8R+e/SiAi18HSO5kk+QbGviCtmIMUd+ikN4Y+tcghxsabvNdh5P wW8+5TZRbD/hJ559AwPIAOff5xArYH3UQGLDFRMp+Rf9ZGW1b7DNDE639Ei4U0Tf5HZ2 ZxRkTkUMQIw9ifeLGwbVOz0smOCUeKcu1Rlyx205da+GcVt609e/NwgY68RgIRRMnYN8 DWYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=JpTZxSWXvPuXwN+s71gMSivTK1157x1lkGpjffTT2YY=; b=bJTmKS88DYjU68H5+/LM/bmfxuEJg/lcPBLbwh1x+353dFixozDqLUaJuVg0VX12Iz R1KXt7Fjgc1pJCodvKicx9C8FqtiYXGJ5BSn5/OH5P+U+Q9nR+zmZxeBDrBGciTdhT8s SNjc8GxiLVyOKxFDoZOqY+th5cZ6NA4q/nCyFK8QxdBa4kIa2DVDTw4JVJXBV9xJ2Lso NX8oRiM9UVs3qY6ABmOc3TtlpndKXh/JM5MhuLIeYJ5IyGWc86EJ/4EKyPUfEUpAMezR Mo3YL2uuiukTsPst1g3V8p87wdD0TIMPVHPJn0nh3r3x3FeVVq5J62G5CsHznRw+jezM EVFA== X-Gm-Message-State: AMke39l+kqUrQ0KMh8l2N17XHYOL0BG9RFjv8T3L9F3+8IG3BTmrZ2LEM8ZFXNCxPVxi2LpXDJI318aXp/FTww== X-Received: by 10.55.116.70 with SMTP id p67mr17370054qkc.216.1488839750222; Mon, 06 Mar 2017 14:35:50 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <88608944-14c9-9d28-80d1-32283521683b@gmail.com> From: "H.J. Lu" Date: Sun, 01 Jan 2017 00:00:00 -0000 Message-ID: Subject: Re: RFC: ABI support for special memory area To: Suprateeka R Hegde Cc: "Carlos O'Donell" , gnu-gabi@sourceware.org Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2017-q1/txt/msg00013.txt.bz2 On Mon, Mar 6, 2017 at 5:25 AM, Suprateeka R Hegde wrote: > On 04-Mar-2017 07:37 AM, Carlos O'Donell wrote: >> >> On 03/03/2017 11:00 AM, H.J. Lu wrote: >>> >>> __gnu_mbind_setup is called from ld.so. Since there is only one ld.so, >>> it needs to know what to pass to __gnu_mbind_setup. Not all arguments >>> have to be used by all implementations nor all memory types. >> >> >> I think what Supra is suggesting is a pointer-to-implementation interface >> which would allow ld.so to pass completely different arguments to the >> library depending on what kind of memory is being defined by the sh_info >> value. It avoids needing to encode all the types in the API, and just >> uses an incomplete pointer to the type. > > > Thats absolutely right. > > However, I am not suggesting one is better over the other. I just want to > get clarity on how the code looks like for different implementations. > > On 03-Mar-2017 09:30 PM, H.J. Lu wrote: >> >> __gnu_mbind_setup is called from ld.so. Since there is only one ld.so, >> it needs to know what to pass to __gnu_mbind_setup. > > > So I want to know what is that ONE-FIXED-FORM of __gnu_mbind_setup being > called by ld.so. > >> Not all arguments >> have to be used by all implementations nor all memory types. > > > I think I am still not getting this. Really sorry for that. Would it be > possible for you to write a small pseudo code that depicts how this design > looks like for different implementations? > For my usage, I only want to know memory type, address and its size: #define _GNU_SOURCE #include #include #include #include #include #include #include #ifdef LIBMBIND_DEBUG #include #endif /* High-Bandwidth Memory node mask. */ static struct bitmask *hbw_node_mask; /* Initialize High-Bandwidth Memory node mask. This must be called before __gnu_mbind_setup. */ static void __attribute__ ((used, constructor)) init_node_mask (void) { if (__get_cpuid_max (0, 0) == 0) return; /* Check if vendor is Intel. */ uint32_t eax, ebx, ecx, edx; __cpuid (0, eax, ebx, ecx, edx); if (!(ebx == 0x756e6547 && ecx == 0x6c65746e && edx == 0x49656e69)) return; /* Get family and model. */ uint32_t model; uint32_t family; __cpuid (1, eax, ebx, ecx, edx); family = (eax >> 8) & 0x0f; if (family != 0x6) return; model = (eax >> 4) & 0x0f; model += (eax >> 12) & 0xf0; /* Check for KNL and KNM. */ switch (model) { default: return; case 0x57: /* Knights Landing. */ case 0x85: /* Knights Mill. */ break; } /* Check if NUMA configuration is supported. */ int nodes_num = numa_num_configured_nodes (); if (nodes_num < 2) return; /* Get MCDRAM NUMA nodes. */ struct bitmask *node_mask = numa_allocate_nodemask (); struct bitmask *node_cpu = numa_allocate_cpumask (); int i; for (i = 0; i < nodes_num; i++) { numa_node_to_cpus (i, node_cpu); /* NUMA node without CPU is MCDRAM node. */ if (numa_bitmask_weight (node_cpu) == 0) numa_bitmask_setbit (node_mask, i); } if (numa_bitmask_weight (node_mask) != 0) { /* On Knights Landing and Knights Mill, MCDRAM is High-Bandwidth Memory. */ hbw_node_mask = node_mask; } else numa_bitmask_free (node_mask); numa_bitmask_free (node_cpu); } /* Support all different memory types. */ static int mbind_setup (unsigned int type, void *addr, size_t length, unsigned int mode, unsigned int flags) { int err = ENXIO; switch (type) { default: #ifdef LIBMBIND_DEBUG printf ("Unsupported mbind type %d: from %p of size %p\n", type, addr, length); #endif return EINVAL; case GNU_MBIND_HBW: if (hbw_node_mask) err = mbind (addr, length, mode, hbw_node_mask->maskp, hbw_node_mask->size, flags); break; } if (err < 0) err = errno; #ifdef LIBMBIND_DEBUG printf ("Mbind type %d: from %p of size %p\n", type, addr, length); #endif return err; } int __gnu_mbind_setup (unsigned int type, void *addr, size_t length) { return mbind_setup (type, addr, length, MPOL_BIND, MPOL_MF_MOVE); } If other memory types need additional information, they can be passed to __gnu_mbind_setup. We just need to know what information is needed. -- H.J.