Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp236826ybt; Tue, 7 Jul 2020 21:42:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxuxfAY2yd15Ds2yRvLJ19yu02CCRJssxLwFTb2zrMy81sggoVFD5YkzQhE/8PZh7U+LHa8 X-Received: by 2002:a17:906:95d6:: with SMTP id n22mr50251147ejy.138.1594183352914; Tue, 07 Jul 2020 21:42:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594183352; cv=none; d=google.com; s=arc-20160816; b=QhIRTDymidCCrLhlRwDqpvgkJLX3jzPkoGElo2fLc6fTp9/mtc5iNzkg2g9x+LI7LK +3lUza1zQez6XBopITQ2wsxdGsxn8NBLiQlVdMMAt8T604553YynaU9z1SpP8VzO97kc puE6j0lUjHg361pD5v4XIX4vd7GiRlQOHkPgJBnINHxK9CqMloexztdX09BfvvGJ+g5y rXVjEzTFJYv2II522Y2PjHdxi9CP+dnjqaRKLW8GSQzkauGDhEsV3gFJbKWQJhou1967 z3/S8ENATCKroW0Zu0RlCLqJ9BWgxdMj4vng65HX5iN5Zc9vmkYaXAy8wJZvwtnZFUkq hgyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=8dNw96B96eIbQP472P+15i/r4t0gFAYtc8zARUaecF0=; b=hIAh4dHeIaHtWTfurJuB6nXGqt/2hJh8PzLQ8JMMLuaipJFerPTC7I/M64GXiKvFpR rrvOqQ4kb0VgayJNXdvTZ2EqdO0+N1jBiYfvHthGeANpiMtVCnABtp/EcxRwXoRtLUXz UgzjV5oHw/7sGH4U4yaappsPYdcSeEncK0WSRdNJSrcCW1d6VGAjX2ttvg9WJQJu8teW Y1J+1AHRSjFxz/W4p9MhG6CXfiPwDhI0w3hK+w0P8zBBy/FnV9GVh2Vrg8OlBxVtT7QN bxbvtto+JbQIZgH1lb5CUJ153l5cQwAaB+lvMvV1GlrBxTPoSskm//w3BNjKMDJm/tRe zbaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=NuIWqyja; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d2si15984220ejy.718.2020.07.07.21.41.58; Tue, 07 Jul 2020 21:42:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=NuIWqyja; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726124AbgGHE15 (ORCPT + 99 others); Wed, 8 Jul 2020 00:27:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725446AbgGHE14 (ORCPT ); Wed, 8 Jul 2020 00:27:56 -0400 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F0FDC061755 for ; Tue, 7 Jul 2020 21:27:56 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id w16so48924066ejj.5 for ; Tue, 07 Jul 2020 21:27:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8dNw96B96eIbQP472P+15i/r4t0gFAYtc8zARUaecF0=; b=NuIWqyjaegQ19QFyhYTJ0y36/0eMyFNfJBL+jmN/1SvmxqjSyG5lJHJdWcy9wXyg4M zy7lOCo2bw1cinVxH1l3+0WrbURYr2eYuQNJEMnxBG3T4CgExMU46UqZQixd1aj78OUM 78/CptqirWWbUEI84ihTiqSnnw6yzzVair+mKB6+l4zzftMrRjKpPkMugswhpdluXKgJ aoVSiSO57Cu3iMf+t6CNs56lDskou5ghNPRZMbdiMiQ41mUM5Re5Cw+4/KfHHF7dgIxH /pgQXq91bIOxcuCa3VaYk2y7noic6S7FI7vxllIz77rUivHIylJMRIgHQ2C2LMe1MUQQ J9aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8dNw96B96eIbQP472P+15i/r4t0gFAYtc8zARUaecF0=; b=KEeze/+LZavv0qFuvvRmxeSQjh/mv922TvqBj2Y5yI3VEEF556Lu0cUw1PiFA/rrof zwQ2eGL3SSJQVHrVieTiReik9+h17AxYjYIyrSdVl2n9GpAOHN6BtCXrUVQ7T9NRUyQV gRsG5yqTmdwF6iCYmyCYJwJcYTs+jTYpdVNLLjLXsRYQeEy5hobkHorDmpiBVU/oOI4l 9sACZKuzDYMcujresBs2CaVi3eE3JSU/B2aGeGh1WkdaeKPVwwljZhErVP7/9JT0TmLZ qQyry2wvLCZXyIxemBeEC1ZEoPSEj2VPC8rIVqvdiIo6hbmMTwVGF4O+AmXWUuL+U/Vy LBkw== X-Gm-Message-State: AOAM530UjGQWDidEKPd4D9XCPPSIvUOyFZcU9kJdtYQPtYXP3k0/OHD0 r2p3Nt1R3ihtzIw5Lxj1P5+xfKyhmbu9vJ6vk/f2lA== X-Received: by 2002:a17:906:da0f:: with SMTP id fi15mr48990019ejb.237.1594182475031; Tue, 07 Jul 2020 21:27:55 -0700 (PDT) MIME-Version: 1.0 References: <20200707055917.143653-1-justin.he@arm.com> <20200707055917.143653-2-justin.he@arm.com> <20200707115454.GN5913@dhcp22.suse.cz> In-Reply-To: From: Dan Williams Date: Tue, 7 Jul 2020 21:27:43 -0700 Message-ID: Subject: Re: [PATCH v2 1/3] arm64/numa: export memory_add_physaddr_to_nid as EXPORT_SYMBOL_GPL To: Justin He Cc: Michal Hocko , David Hildenbrand , Catalin Marinas , Will Deacon , Vishal Verma , Dave Jiang , Andrew Morton , Mike Rapoport , Baoquan He , Chuhong Yuan , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "linux-nvdimm@lists.01.org" , Kaly Xin Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 7, 2020 at 9:08 PM Justin He wrote: [..] > > Especially for architectures that use memblock info for numa info > > (which seems to be everyone except x86) why not implement a generic > > memory_add_physaddr_to_nid() that does: > > > > int memory_add_physaddr_to_nid(u64 addr) > > { > > unsigned long start_pfn, end_pfn, pfn = PHYS_PFN(addr); > > int nid; > > > > for_each_online_node(nid) { > > get_pfn_range_for_nid(nid, &start_pfn, &end_pfn); > > if (pfn >= start_pfn && pfn <= end_pfn) > > return nid; > > } > > return NUMA_NO_NODE; > > } > > Thanks for your suggestion, > Could I wrap the codes and let memory_add_physaddr_to_nid simply invoke > phys_to_target_node()? I think it needs to be the reverse. phys_to_target_node() should call memory_add_physaddr_to_nid() by default, but fall back to searching reserved memory address ranges in memblock. See phys_to_target_node() in arch/x86/mm/numa.c. That one uses numa_meminfo instead of memblock, but the principle is the same i.e. that a target node may not be represented in memblock.memory, but memblock.reserved. I'm working on a patch to provide a function similar to get_pfn_range_for_nid() that operates on reserved memory.