Linux-mm Archive on lore.kernel.org
 help / color / Atom feed
From: Minchan Kim <minchan@kernel.org>
To: Dan Carpenter <dan.carpenter@oracle.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
	linux-mm@kvack.org
Subject: Re: zsmalloc: support compaction
Date: Tue, 7 Jun 2016 13:51:46 +0900
Message-ID: <20160607045146.GF26230@bbox> (raw)
In-Reply-To: <20160606201151.GA26398@mwanda>

On Mon, Jun 06, 2016 at 11:11:51PM +0300, Dan Carpenter wrote:
> Hello Minchan Kim,
> 
> The patch 312fcae22703: "zsmalloc: support compaction" from Apr 15,
> 2015, leads to the following static checker warning:
> 
> 	mm/zsmalloc.c:1521 obj_malloc()
> 	warn: 'OBJ_ALLOCATED_TAG' is a shifter (not for '|=').
> 
> mm/zsmalloc.c
>   1510  static unsigned long obj_malloc(struct size_class *class,
>   1511                                  struct zspage *zspage, unsigned long handle)
>   1512  {
>   1513          int i, nr_page, offset;
>   1514          unsigned long obj;
>   1515          struct link_free *link;
>   1516  
>   1517          struct page *m_page;
>   1518          unsigned long m_offset;
>   1519          void *vaddr;
>   1520  
>   1521          handle |= OBJ_ALLOCATED_TAG;
>                           ^^^^^^^^^^^^^^^^^
> It's weird to use the same define for a bit number
> 
>   1522          obj = get_freeobj(zspage);
>   1523  
>   1524          offset = obj * class->size;
>   1525          nr_page = offset >> PAGE_SHIFT;
>   1526          m_offset = offset & ~PAGE_MASK;
>   1527          m_page = get_first_page(zspage);
>   1528  
>   1529          for (i = 0; i < nr_page; i++)
>   1530                  m_page = get_next_page(m_page);
>   1531  
>   1532          vaddr = kmap_atomic(m_page);
>   1533          link = (struct link_free *)vaddr + m_offset / sizeof(*link);
>   1534          set_freeobj(zspage, link->next >> OBJ_ALLOCATED_TAG);
>                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> And also a bit shifter.  TAG normally implies it is a bit and not a
> shift?

Thanks for the report, Dan!

      reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-06 20:11 Dan Carpenter
2016-06-07  4:51 ` Minchan Kim [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160607045146.GF26230@bbox \
    --to=minchan@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=dan.carpenter@oracle.com \
    --cc=linux-mm@kvack.org \
    --cc=sergey.senozhatsky.work@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-mm Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mm/0 linux-mm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mm linux-mm/ https://lore.kernel.org/linux-mm \
		linux-mm@kvack.org
	public-inbox-index linux-mm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kvack.linux-mm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git