From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw0-f181.google.com (mail-yw0-f181.google.com [209.85.161.181]) by dpdk.org (Postfix) with ESMTP id 417042C72 for ; Thu, 2 Jun 2016 11:12:53 +0200 (CEST) Received: by mail-yw0-f181.google.com with SMTP id h19so44202736ywc.0 for ; Thu, 02 Jun 2016 02:12:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=zD90MtKEOjNvKSSL5XcuHQHUflTQFMxMbLgDJg5wEk8=; b=g1gOHjU4RciuEZCPg8oeuW5LkihbflFYG4njjAz545cSQrI+CUCk804TjvU0zWHm4a TJDiRiNVs/EUPxRxYfaDBdhQXwTxREDRcdj+zgSQkX2s46UutAyY0nguNVdeTvTnmXpV ry+0+Cbis8WPk0BWoJhsPRgjd6RHHLhYhLFDg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=zD90MtKEOjNvKSSL5XcuHQHUflTQFMxMbLgDJg5wEk8=; b=gcuvgksGKLICOLggNf60iRnZha7jflQzZFsfIiz/FxNkV9M2uMdptXQ2HkgQwmilSx 6cIVlQctwGe0XV3nbHbvUWUbIe3ttA60TTptzvwKqrVqM20tFCOJZYLuFxE6d9AGCqdk porEhZHCkYIXV9i8XY873qiaRhKvFoOvZ2/ckR5Td5Fhh7AgQbWVjf+dqAJGUGU++PJ/ 0YAEkB2A24wa8vWjXCxHBG2Ak+A9zWtvFGzEqAMfq8722+J3xY+R5sjdGy7Z/NxlenfU NiyYy3Mek4iFKXGZ9cDjEEjTX4dlQkrnh4w+l+Z0j6i9n+/OXyd591Niwp4ka5OVihQu 1lbQ== X-Gm-Message-State: ALyK8tLlJMlM5J+LABDkot6/XKD06EjwnzwPA/OvmEuK6iNrV/cpaCQwu+0XPUsTyMqyIPttfXCRJQTiBFhfxblw MIME-Version: 1.0 X-Received: by 10.37.195.133 with SMTP id t127mr4723582ybf.149.1464858769745; Thu, 02 Jun 2016 02:12:49 -0700 (PDT) Received: by 10.37.212.146 with HTTP; Thu, 2 Jun 2016 02:12:49 -0700 (PDT) In-Reply-To: <574FDBED.8050003@6wind.com> References: <1464663966-8122-1-git-send-email-jianbo.liu@linaro.org> <574DE5D6.2040001@6wind.com> <574FDBED.8050003@6wind.com> Date: Thu, 2 Jun 2016 17:12:49 +0800 Message-ID: From: Jianbo Liu To: Olivier MATZ Cc: Jerin Jacob , dev@dpdk.org Content-Type: text/plain; charset=UTF-8 Subject: Re: [dpdk-dev] [PATCH] mbuf: extend rte_mbuf_prefetch_part* to support more prefetching methods X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Jun 2016 09:12:53 -0000 On 2 June 2016 at 15:10, Olivier MATZ wrote: > Hi Jianbo, > > On 06/01/2016 05:29 AM, Jianbo Liu wrote: >>> enum rte_mbuf_prefetch_type { >>> > PREFETCH0, >>> > PREFETCH1, >>> > ... >>> > }; >>> > >>> > static inline void >>> > rte_mbuf_prefetch_part1(enum rte_mbuf_prefetch_type type, >>> > struct rte_mbuf *m) >>> > { >>> > switch (type) { >>> > case PREFETCH0: >>> > rte_prefetch0(&m->cacheline0); >>> > break; >>> > case PREFETCH1: >>> > rte_prefetch1(&m->cacheline0); >>> > break; >>> > ... >>> > } >>> > >> How about adding these to forbid the illegal use of this macro? >> enum rte_mbuf_prefetch_type { >> ENUM_prefetch0, >> ENUM_prefetch1, >> ... >> }; >> >> #define RTE_MBUF_PREFETCH_PART1(type, m) \ >> if (ENUM_##type == ENUM_prefretch0) \ >> rte_prefetch0(&(m)->cacheline0); \ >> else if (ENUM_##type == ENUM_prefetch1) \ >> rte_prefetch1(&(m)->cacheline0); \ >> .... >> > > As Stephen stated, a static inline is better than a macro, mainly > because it is understood by the compiler instead of beeing a dumb > code replacement. > > Any reason why you would prefer a macro in that case? > For the simplicity reason. If not, we may have to write several similar functions for different prefetchings.